• Do you like that ?

    From Bonita Montero@21:1/5 to All on Sun Nov 5 20:06:42 2023
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Bonita Montero on Sun Nov 5 20:02:24 2023
    On 2023-11-05, Bonita Montero <[email protected]> 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: @[email protected]
    NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Kaz Kylheku on Sun Nov 5 21:42:05 2023
    Kaz Kylheku <[email protected]> writes:

    On 2023-11-05, Bonita Montero <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Ben Bacarisse on Sun Nov 5 23:09:50 2023
    On 05/11/2023 22:42, Ben Bacarisse wrote:
    Kaz Kylheku <[email protected]> writes:

    On 2023-11-05, Bonita Montero <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Mon Nov 6 09:33:30 2023
    Am 05.11.2023 um 21:02 schrieb Kaz Kylheku:
    On 2023-11-05, Bonita Montero <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Bonita Montero on Mon Nov 6 17:50:26 2023
    On 2023-11-06, Bonita Montero <[email protected]> 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: @[email protected]
    NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Mon Nov 6 19:01:09 2023
    Am 06.11.2023 um 18:50 schrieb Kaz Kylheku:
    On 2023-11-06, Bonita Montero <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Bonita Montero on Mon Nov 6 18:59:01 2023
    On 2023-11-06, Bonita Montero <[email protected]> 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: @[email protected]
    NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bonita Montero@21:1/5 to All on Mon Nov 6 20:07:51 2023
    Am 06.11.2023 um 19:59 schrieb Kaz Kylheku:
    On 2023-11-06, Bonita Montero <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Bonita Montero on Mon Nov 6 19:10:56 2023
    On 2023-11-06, Bonita Montero <[email protected]> wrote:
    I can imagine

    I've not seen evidence to support this.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris M. Thomasson@21:1/5 to Kaz Kylheku on Mon Nov 6 12:17:20 2023
    On 11/6/2023 9:50 AM, Kaz Kylheku wrote:
    On 2023-11-06, Bonita Montero <[email protected]> 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!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Brown@21:1/5 to Kaz Kylheku on Tue Nov 7 08:57:08 2023
    On 06/11/2023 20:10, Kaz Kylheku wrote:
    On 2023-11-06, Bonita Montero <[email protected]> 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)