C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Std-Proposals Digest, Vol 74, Issue 25

From: Tymi <tymi.cpp_at_[hidden]>
Date: Wed, 14 May 2025 10:16:54 +0200
I don't understand the difference between that and a lambda tbh
I might be misunderstanding something though, or maybe missing the point of
possible optimisations here

On Wed, 14 May 2025, 08:44 , <std-proposals-request_at_[hidden]> wrote:

> Send Std-Proposals mailing list submissions to
> std-proposals_at_[hidden]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> or, via email, send a message with subject or body 'help' to
> std-proposals-request_at_[hidden]
>
> You can reach the person managing the list at
> std-proposals-owner_at_[hidden]
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Std-Proposals digest..."
>
>
> Today's Topics:
>
> 1. switch expression/matching switch expression (Tymi)
> 2. Re: switch expression/matching switch expression (Tymi)
> 3. Re: switch expression/matching switch expression (Pavel Vazharov)
> 4. Re: switch expression/matching switch expression (Pavel Vazharov)
> 5. Re: switch expression/matching switch expression (Tymi)
> 6. Re: switch expression/matching switch expression
> (Sebastian Wittmeier)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 14 May 2025 07:05:25 +0200
> From: Tymi <tymi.cpp_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: [std-proposals] switch expression/matching switch expression
> Message-ID:
> <CA+OkEO5pdv46k9Y=mk9bpFOgG=
> ZZ7ZWmuY-D6kLvtdp8uZa2oQ_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> A matching switch expression could be useful and could get optimised into a
> jump table
> ```cpp
> int meow = 5;
> int purr = switch(meow)
> {
> case 5: 123;
> case 123: 321;
> default: throw nullptr;
> };```
> Whatever the syntax would be, this is just an example and it can definitely
> improve
>
> Tymi.
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Message: 2
> Date: Wed, 14 May 2025 07:08:17 +0200
> From: Tymi <tymi.cpp_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <CA+OkEO6wv7i8hbh5cj0=
> 0xNUrS3mE2xjBUVsDyU5EC+Bhm-7Pw_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> ```cpp
> int purr = meow == 5 ? 123
> : meow == 123 ? 321
> : throw nullptr;
> ```
> This is what I do now
>
>
> On Wed, 14 May 2025, 07:05 Tymi, <tymi.cpp_at_[hidden]> wrote:
>
> > A matching switch expression could be useful and could get optimised into
> > a jump table
> > ```cpp
> > int meow = 5;
> > int purr = switch(meow)
> > {
> > case 5: 123;
> > case 123: 321;
> > default: throw nullptr;
> > };```
> > Whatever the syntax would be, this is just an example and it can
> > definitely improve
> >
> > Tymi.
> >
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Message: 3
> Date: Wed, 14 May 2025 08:09:35 +0300
> From: Pavel Vazharov <freakpv_at_[hidden]>
> To: std-proposals_at_[hidden]
> Cc: Tymi <tymi.cpp_at_[hidden]>
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <CAK9EM1-YP=
> nEHLerbjd5sffT98NYBQuTS-VYV2VJ3cafJhA7ZQ_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> On Wed, May 14, 2025 at 8:05?AM Tymi via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
> > A matching switch expression could be useful and could get optimised into
> > a jump table
> > ```cpp
> > int meow = 5;
> > int purr = switch(meow)
> > {
> > case 5: 123;
> > case 123: 321;
> > default: throw nullptr;
> > };```
> > Whatever the syntax would be, this is just an example and it can
> > definitely improve
> >
> It's probably covered by the proposed pattern matching
> <https://wg21.link/p2688>
>
> >
> > Tymi.
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> >
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Message: 4
> Date: Wed, 14 May 2025 08:11:50 +0300
> From: Pavel Vazharov <freakpv_at_[hidden]>
> To: std-proposals_at_[hidden]
> Cc: Tymi <tymi.cpp_at_[hidden]>
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <
> CAK9EM1-U8vH8Go2jDb+Yb_Ptxa8o9SQGgTrxon5uuo5JGnYu9Q_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> On Wed, May 14, 2025 at 8:09?AM Pavel Vazharov <freakpv_at_[hidden]> wrote:
>
> >
> > On Wed, May 14, 2025 at 8:05?AM Tymi via Std-Proposals <
> > std-proposals_at_[hidden]> wrote:
> >
> >> A matching switch expression could be useful and could get optimised
> into
> >> a jump table
> >> ```cpp
> >> int meow = 5;
> >> int purr = switch(meow)
> >> {
> >> case 5: 123;
> >> case 123: 321;
> >> default: throw nullptr;
> >> };```
> >> Whatever the syntax would be, this is just an example and it can
> >> definitely improve
> >>
> > It's probably covered by the proposed pattern matching
> > <https://wg21.link/p2688>
> > And/or by the proposed do expressions <https://wg21.link/p2806>.
> >
> >>
> >> Tymi.
> >> --
> >> Std-Proposals mailing list
> >> Std-Proposals_at_[hidden]
> >> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> >>
> >
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Message: 5
> Date: Wed, 14 May 2025 07:13:17 +0200
> From: Tymi <tymi.cpp_at_[hidden]>
> To: Pavel Vazharov <freakpv_at_[hidden]>, std-proposals_at_[hidden]
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <
> CA+OkEO5zrBXjkjBdgJVpEQPsJKfQ_dmK0sOXX+exniDkhQh-_Q_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> That's exactly what I wanted! Thanks, didn't know someone else would make
> that proposal.
>
> Tymi.
>
> On Wed, 14 May 2025, 07:12 Pavel Vazharov, <freakpv_at_[hidden]> wrote:
>
> >
> >
> > On Wed, May 14, 2025 at 8:09?AM Pavel Vazharov <freakpv_at_[hidden]>
> wrote:
> >
> >>
> >> On Wed, May 14, 2025 at 8:05?AM Tymi via Std-Proposals <
> >> std-proposals_at_[hidden]> wrote:
> >>
> >>> A matching switch expression could be useful and could get optimised
> >>> into a jump table
> >>> ```cpp
> >>> int meow = 5;
> >>> int purr = switch(meow)
> >>> {
> >>> case 5: 123;
> >>> case 123: 321;
> >>> default: throw nullptr;
> >>> };```
> >>> Whatever the syntax would be, this is just an example and it can
> >>> definitely improve
> >>>
> >> It's probably covered by the proposed pattern matching
> >> <https://wg21.link/p2688>
> >> And/or by the proposed do expressions <https://wg21.link/p2806>.
> >>
> >>>
> >>> Tymi.
> >>> --
> >>> Std-Proposals mailing list
> >>> Std-Proposals_at_[hidden]
> >>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> >>>
> >>
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Message: 6
> Date: Wed, 14 May 2025 08:37:27 +0200
> From: Sebastian Wittmeier <wittmeier_at_[hidden]>
> To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <
> zarafa.68243a27.3fd4.13716d4a36b15924_at_lvps176-28-11-36.dedicated.hosteurope.
> >
>
> Content-Type: text/plain; charset="utf-8"
>
> Also have a look at do-expressions:
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2806r3.html
>
> ?
> int purr = do {
> ??? switch(meow)
> ??? {
> ? ? ? ?? case 5: do_return 123;
> ? ? ? ?? case 123: do_return 321;
> ? ? ? ?? default: throw nullptr;
> ??? };
> };
>
> ?
> ?
> They can (if accepted) also be combined with pattern-matching:
>
> ?
> int purr = meow match {
> ? ?? 5 => do { do_return 123; };
> ? ?? 123 => do { do_return 321; };
> ? ?? _ => do { throw nullptr; };
> };
>
> ?
>
> ?
> ?
> ?
> ?
>
> ?
> -----Urspr?ngliche Nachricht-----
> Von:Tymi via Std-Proposals <std-proposals_at_[hidden]>
> Gesendet:Mi 14.05.2025 07:05
> Betreff:[std-proposals] switch expression/matching switch expression
> An:std-proposals_at_[hidden];
> CC:Tymi <tymi.cpp_at_[hidden]>;
>
> A matching switch expression could be useful and could get optimised into
> a jump table?
> ```cpp
> int meow = 5;
> int purr = switch(meow)
> {
> ? ? ?case 5: 123;
> ? ? ?case 123: 321;
> ? ? ?default: throw nullptr;
> };```
> Whatever the syntax would be, this is just an example and it can
> definitely improve?
> ?Tymi.
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>
>
> -------------- next part --------------
> HTML attachment scrubbed and removed
>
> ------------------------------
>
> Subject: Digest Footer
>
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
>
> ------------------------------
>
> End of Std-Proposals Digest, Vol 74, Issue 25
> *********************************************
>

Received on 2025-05-14 08:17:09