Date: Wed, 14 May 2025 19:42:08 +0200
Yeah. I like how C# handles it for instance. I think P2688 already
covers it anyway
On 14.05.2025 14:00, 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. Re: switch expression/matching switch expression (Richard Hodges)
> 2. Re: switch expression/matching switch expression (Andrey Semashev)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 14 May 2025 11:29:26 +0200
> From: Richard Hodges <hodges.r_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <CALvx3hY2R5Cq31ZpfvjMiK7sDcKUOQ06=jXPLRrLFJ7y0ptW-g_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> <sigh> C++ used to be a simple, elegant language?
>
> On Wed, 14 May 2025 at 08:44, Sebastian Wittmeier via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> 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
>>
>> --
>> 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: 2
> Date: Wed, 14 May 2025 12:40:28 +0300
> From: Andrey Semashev <andrey.semashev_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID: <82f408af-3817-4b6c-b159-578cd3e3d611_at_[hidden]>
> Content-Type: text/plain; charset=UTF-8
>
> On 14 May 2025 08:05, Tymi via Std-Proposals 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?
> How would it be better than a usual switch/case?
>
>
>
> ------------------------------
>
> 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 27
> *********************************************
covers it anyway
On 14.05.2025 14:00, 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. Re: switch expression/matching switch expression (Richard Hodges)
> 2. Re: switch expression/matching switch expression (Andrey Semashev)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 14 May 2025 11:29:26 +0200
> From: Richard Hodges <hodges.r_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID:
> <CALvx3hY2R5Cq31ZpfvjMiK7sDcKUOQ06=jXPLRrLFJ7y0ptW-g_at_[hidden]>
> Content-Type: text/plain; charset="utf-8"
>
> <sigh> C++ used to be a simple, elegant language?
>
> On Wed, 14 May 2025 at 08:44, Sebastian Wittmeier via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> 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
>>
>> --
>> 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: 2
> Date: Wed, 14 May 2025 12:40:28 +0300
> From: Andrey Semashev <andrey.semashev_at_[hidden]>
> To: std-proposals_at_[hidden]
> Subject: Re: [std-proposals] switch expression/matching switch
> expression
> Message-ID: <82f408af-3817-4b6c-b159-578cd3e3d611_at_[hidden]>
> Content-Type: text/plain; charset=UTF-8
>
> On 14 May 2025 08:05, Tymi via Std-Proposals 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?
> How would it be better than a usual switch/case?
>
>
>
> ------------------------------
>
> 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 27
> *********************************************
Received on 2025-05-14 17:42:12