Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #117598 > unrolled thread

Do you like that ?

Started byBonita Montero <Bonita.Montero@gmail.com>
First post2023-11-05 20:06 +0100
Last post2023-11-06 12:17 -0800
Articles 12 — 5 participants

Back to article view | Back to comp.lang.c++


Contents

  Do you like that ? Bonita Montero <Bonita.Montero@gmail.com> - 2023-11-05 20:06 +0100
    Re: Do you like that ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-11-05 20:02 +0000
      Re: Do you like that ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-11-05 21:42 +0000
        Re: Do you like that ? David Brown <david.brown@hesbynett.no> - 2023-11-05 23:09 +0100
      Re: Do you like that ? Bonita Montero <Bonita.Montero@gmail.com> - 2023-11-06 09:33 +0100
        Re: Do you like that ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-11-06 17:50 +0000
          Re: Do you like that ? Bonita Montero <Bonita.Montero@gmail.com> - 2023-11-06 19:01 +0100
            Re: Do you like that ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-11-06 18:59 +0000
              Re: Do you like that ? Bonita Montero <Bonita.Montero@gmail.com> - 2023-11-06 20:07 +0100
                Re: Do you like that ? Kaz Kylheku <864-117-4973@kylheku.com> - 2023-11-06 19:10 +0000
                  Re: Do you like that ? David Brown <david.brown@hesbynett.no> - 2023-11-07 08:57 +0100
          Re: Do you like that ? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-11-06 12:17 -0800

#117598 — Do you like that ?

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-11-05 20:06 +0100
SubjectDo you like that ?
Message-ID<ui8p3t$3rpn$1@raubtier-asyl.eternal-september.org>
using XHANDLE = std::unique_ptr<void, decltype([]( void *h ) { h != 
INVALID_HANDLE_VALUE && h && CloseHandle( h ); })>;

A Win32 HANDLE-wrapper in just one line in C++20.
C++20 allows lambdas in an unevaluated context.

[toc] | [next] | [standalone]


#117599

FromKaz Kylheku <864-117-4973@kylheku.com>
Date2023-11-05 20:02 +0000
Message-ID<20231105115656.935@kylheku.com>
In reply to#117598
On 2023-11-05, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> using XHANDLE = std::unique_ptr<void, decltype([]( void *h ) { h != 
> INVALID_HANDLE_VALUE && h && CloseHandle( h ); })>;
>
> A Win32 HANDLE-wrapper in just one line in C++20.
> C++20 allows lambdas in an unevaluated context.

So what?

1960 Lisp allows lambdas in unevaluated context.

  (QUOTE (LAMBDA (H)
           (AND (NOT (INVALIDHANDLE H))
                (CLOSEHANDLE H))))

This is just C++ catching up to something that existed when
Stroustrup was in elementary school.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

[toc] | [prev] | [next] | [standalone]


#117606

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2023-11-05 21:42 +0000
Message-ID<87a5rr6fo2.fsf@bsb.me.uk>
In reply to#117599
Kaz Kylheku <864-117-4973@kylheku.com> writes:

> On 2023-11-05, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> using XHANDLE = std::unique_ptr<void, decltype([]( void *h ) { h != 
>> INVALID_HANDLE_VALUE && h && CloseHandle( h ); })>;
>>
>> A Win32 HANDLE-wrapper in just one line in C++20.
>> C++20 allows lambdas in an unevaluated context.
>
> So what?
>
> 1960 Lisp allows lambdas in unevaluated context.
>
>   (QUOTE (LAMBDA (H)
>            (AND (NOT (INVALIDHANDLE H))
>                 (CLOSEHANDLE H))))
>
> This is just C++ catching up to something that existed when
> Stroustrup was in elementary school.

I was going to say the usage here is not a good look for C++.  As a
language with compile-time type checking why is decltype needed?  It's
usually because C++ can't express the type involved any other way and
that's not something to shout about.

But then it turns out I don't know what's going on.  This program:

  #include <iostream>
  #include <memory>

  using uptr_int = std::unique_ptr<int, decltype([](int *ip) {
     std::cout << "delete (" << *ip << ")\n";
  })>;

  int main()
  {
     int x = 42;
     uptr_int ip(&x);
  }

prints "delete (42)".  Why?  I thought decltype was just being used to
give a type for the std::unique_ptr template instantiation, but it seems
to supply the function too.  What's going on?

Having used C++ from the early CFront days, and watched balloon in size
and complexity, I knew the day would come when even a short C++ program
would be mystery to me.  That day has come!

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#117607

FromDavid Brown <david.brown@hesbynett.no>
Date2023-11-05 23:09 +0100
Message-ID<ui93re$5dm1$1@dont-email.me>
In reply to#117606
On 05/11/2023 22:42, Ben Bacarisse wrote:
> Kaz Kylheku <864-117-4973@kylheku.com> writes:
> 
>> On 2023-11-05, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>> using XHANDLE = std::unique_ptr<void, decltype([]( void *h ) { h !=
>>> INVALID_HANDLE_VALUE && h && CloseHandle( h ); })>;
>>>
>>> A Win32 HANDLE-wrapper in just one line in C++20.
>>> C++20 allows lambdas in an unevaluated context.
>>
>> So what?
>>
>> 1960 Lisp allows lambdas in unevaluated context.
>>
>>    (QUOTE (LAMBDA (H)
>>             (AND (NOT (INVALIDHANDLE H))
>>                  (CLOSEHANDLE H))))
>>
>> This is just C++ catching up to something that existed when
>> Stroustrup was in elementary school.
> 
> I was going to say the usage here is not a good look for C++.  As a
> language with compile-time type checking why is decltype needed?  It's
> usually because C++ can't express the type involved any other way and
> that's not something to shout about.
> 
> But then it turns out I don't know what's going on.  This program:
> 
>    #include <iostream>
>    #include <memory>
> 
>    using uptr_int = std::unique_ptr<int, decltype([](int *ip) {
>       std::cout << "delete (" << *ip << ")\n";
>    })>;
> 
>    int main()
>    {
>       int x = 42;
>       uptr_int ip(&x);
>    }
> 
> prints "delete (42)".  Why?  I thought decltype was just being used to
> give a type for the std::unique_ptr template instantiation, but it seems
> to supply the function too.  What's going on?
> 
> Having used C++ from the early CFront days, and watched balloon in size
> and complexity, I knew the day would come when even a short C++ program
> would be mystery to me.  That day has come!
> 

I think the type of a lambda encodes the definition of the lambda (so 
that each lambda function has a unique type, perhaps).  But I don't know 
why it appears to be executing the lambda.

[toc] | [prev] | [next] | [standalone]


#117623

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-11-06 09:33 +0100
Message-ID<uia8cp$de84$1@raubtier-asyl.eternal-september.org>
In reply to#117599
Am 05.11.2023 um 21:02 schrieb Kaz Kylheku:
> On 2023-11-05, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> using XHANDLE = std::unique_ptr<void, decltype([]( void *h ) { h !=
>> INVALID_HANDLE_VALUE && h && CloseHandle( h ); })>;
>>
>> A Win32 HANDLE-wrapper in just one line in C++20.
>> C++20 allows lambdas in an unevaluated context.
> 
> So what?
> 
> 1960 Lisp allows lambdas in unevaluated context.
> 
>    (QUOTE (LAMBDA (H)
>             (AND (NOT (INVALIDHANDLE H))
>                  (CLOSEHANDLE H))))

This is figuratively the definition of a lambda in C++,
but not the derivation of the type, which then maintains
the identity of the call operator.

[toc] | [prev] | [next] | [standalone]


#117626

FromKaz Kylheku <864-117-4973@kylheku.com>
Date2023-11-06 17:50 +0000
Message-ID<20231106082213.771@kylheku.com>
In reply to#117623
On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>    (QUOTE (LAMBDA (H)
>>             (AND (NOT (INVALIDHANDLE H))
>>                  (CLOSEHANDLE H))))
>
> This is figuratively the definition of a lambda in C++,
> but not the derivation of the type, which then maintains
> the identity of the call operator.

This smells like AI-generated word salad?

Aha!

  MORON AI BOT NET
  ||||| || B|| |||
  ||||| ||  O| |||
  ||||| ||   | N||
  ||||| |I   |  ||
  ||||| |    |  |T
  ||||| A    |  |
  M||||      |  |
   O|||      |  |
    ||N      |  |
    ||       T  |
    ||          E 
    R|
     O

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

[toc] | [prev] | [next] | [standalone]


#117627

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-11-06 19:01 +0100
Message-ID<uib9l4$iih7$2@raubtier-asyl.eternal-september.org>
In reply to#117626
Am 06.11.2023 um 18:50 schrieb Kaz Kylheku:
> On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>     (QUOTE (LAMBDA (H)
>>>              (AND (NOT (INVALIDHANDLE H))
>>>                   (CLOSEHANDLE H))))
>>
>> This is figuratively the definition of a lambda in C++,
>> but not the derivation of the type, which then maintains
>> the identity of the call operator.
> 
> This smells like AI-generated word salad?
> 
> Aha!
> 
>    MORON AI BOT NET
>    ||||| || B|| |||
>    ||||| ||  O| |||
>    ||||| ||   | N||
>    ||||| |I   |  ||
>    ||||| |    |  |T
>    ||||| A    |  |
>    M||||      |  |
>     O|||      |  |
>      ||N      |  |
>      ||       T  |
>      ||          E
>      R|
>       O
> 

If you don't understand the meaning its moronic. You've shown
a pure lambda, I've shown how the identity of the lambda is
injected into a class without an actual function object.

[toc] | [prev] | [next] | [standalone]


#117628

FromKaz Kylheku <864-117-4973@kylheku.com>
Date2023-11-06 18:59 +0000
Message-ID<20231106105437.468@kylheku.com>
In reply to#117627
On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> If you don't understand the meaning its moronic. You've shown
                                      ^^^

pron.     possessive     + be     -> contr.

he        his            he is    -> he's
she       her(s)         she is   -> she's
you       your(s)        you are  -> you're

it        its            it is    -> it's

What language model are you using?

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

[toc] | [prev] | [next] | [standalone]


#117629

FromBonita Montero <Bonita.Montero@gmail.com>
Date2023-11-06 20:07 +0100
Message-ID<uibdi7$j9bd$1@raubtier-asyl.eternal-september.org>
In reply to#117628
Am 06.11.2023 um 19:59 schrieb Kaz Kylheku:
> On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> If you don't understand the meaning its moronic. You've shown
>                                        ^^^
> 
> pron.     possessive     + be     -> contr.
> 
> he        his            he is    -> he's
> she       her(s)         she is   -> she's
> you       your(s)        you are  -> you're
> 
> it        its            it is    -> it's
> 
> What language model are you using?

I can imagine that you didn't understand what I said because of that.

[toc] | [prev] | [next] | [standalone]


#117630

FromKaz Kylheku <864-117-4973@kylheku.com>
Date2023-11-06 19:10 +0000
Message-ID<20231106111025.304@kylheku.com>
In reply to#117629
On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
> I can imagine

I've not seen evidence to support this.

[toc] | [prev] | [next] | [standalone]


#117640

FromDavid Brown <david.brown@hesbynett.no>
Date2023-11-07 08:57 +0100
Message-ID<uicqkk$tmi0$1@dont-email.me>
In reply to#117630
On 06/11/2023 20:10, Kaz Kylheku wrote:
> On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>> I can imagine
> 
> I've not seen evidence to support this.

Do all threads in this newsgroup have to descend to a kindergarten level 
of insults?

Whatever people may think of Bonita's original post in this thread, it 
inspired a rather profound and interesting question from Ben.  I for one 
would be happy if the knowledgable regulars here spent more time 
answering questions like his and less time bickering.

[toc] | [prev] | [next] | [standalone]


#117634

From"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Date2023-11-06 12:17 -0800
Message-ID<uibhkf$jujq$4@dont-email.me>
In reply to#117626
On 11/6/2023 9:50 AM, Kaz Kylheku wrote:
> On 2023-11-06, Bonita Montero <Bonita.Montero@gmail.com> wrote:
>>>     (QUOTE (LAMBDA (H)
>>>              (AND (NOT (INVALIDHANDLE H))
>>>                   (CLOSEHANDLE H))))
>>
>> This is figuratively the definition of a lambda in C++,
>> but not the derivation of the type, which then maintains
>> the identity of the call operator.
> 
> This smells like AI-generated word salad?
> 
> Aha!
> 
>    MORON AI BOT NET
>    ||||| || B|| |||
>    ||||| ||  O| |||
>    ||||| ||   | N||
>    ||||| |I   |  ||
>    ||||| |    |  |T
>    ||||| A    |  |
>    M||||      |  |
>     O|||      |  |
>      ||N      |  |
>      ||       T  |
>      ||          E
>      R|
>       O
> 

No shit!

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web