Date: Wed, 14 May 2025 11:29:26 +0200
<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
>
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
>
Received on 2025-05-14 09:29:41