Date: Wed, 24 May 2023 18:49:29 +0200
Indeed the functionality looks very close, thanks !
and that 'do' is clearer than my 'once' meaning (like someone said before)
Le mer. 24 mai 2023 à 18:26, Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> a écrit :
> Perhaps something related to the proposed and actively discussed do
> expressions?
>
> Or they provide already enough functionality for your use case?
>
>
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2806r1.html
>
> https://github.com/cplusplus/papers/issues/1462
>
>
>
>
>
>
>
> do {
>
> if (Failed(Condition0))
>
> do_return;
>
> if (Failed(Condition1))
>
> do_return;
>
> Code_to_execute;
>
> }
>
>
>
> You can even 'do':
>
>
>
> if (do {
>
> if (Failed(Condition0))
>
> do_return false;
>
> if (Succeeded(ConditionShortCut))
>
> do_return true;
>
> if (Failed(Condition1))
>
> do_return false;
>
> return true;
>
> })
>
> Code_to_execute;
>
>
>
> do blocks are compatible with return, break, continue, throw, co_return,
> etc. (and to some degree goto)
>
>
>
> (*do_return* is currently planned instead of *do return*).
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* LUCE Jean-Sébastien via Std-Proposals <
> std-proposals_at_[hidden]>
> *Gesendet:* Mi 24.05.2023 14:58
> *Betreff:* [std-proposals] "once" keyword
> *An:* std-proposals_at_[hidden];
> *CC:* LUCE Jean-Sébastien <jseb.luce_at_[hidden]>;
> Hello
>
> It is often useful to support multiple cancel conditions, like 'return' in
> a function, but without having to isolate the code in such a function
> (which is called from a single point).
>
> I'm used to write code like
>
> "
> do {
> if (Failed(Condition0))
> break;
> if (Failed(Condition1))
> break;
> Code_to_execute;
> } while (0);
> "
> or
>
> "
> while (Condition0) {
> if (Failed(Condition1))
> break;
> Code_to_execute;
> break;
> };
> "
>
> the example above looks trivial and could be replaced by
> if (Succeeded(Condition0) && Succeeded(Condition1)) {
> Code_to_execute;
> }
>
> Yet with more complex condition codes, writing conditions per line is way
> more readable.
>
> The syntaxe is still "hacked" someway, since "continue" could be used
> wrongly, or final "break" may be forgotten.
>
> I would like "once" behave like do { } while(0);, where only "break" (and
> not "continue") would have a meaning.
>
> for example above could be converted as
> "
> once {
> if (Failed(Condition0))
> break;
> if (Failed(Condition1))
> break;
> Code_to_execute;
> }
> "
>
> "
> once (Condition0) {
> if (Failed(Condition1))
> break;
> Code_to_execute;
> }
> "
>
> "once" could be followed or not by a first condition.
>
> Thanks
>
> --
> 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
>
and that 'do' is clearer than my 'once' meaning (like someone said before)
Le mer. 24 mai 2023 à 18:26, Sebastian Wittmeier via Std-Proposals <
std-proposals_at_[hidden]> a écrit :
> Perhaps something related to the proposed and actively discussed do
> expressions?
>
> Or they provide already enough functionality for your use case?
>
>
>
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2806r1.html
>
> https://github.com/cplusplus/papers/issues/1462
>
>
>
>
>
>
>
> do {
>
> if (Failed(Condition0))
>
> do_return;
>
> if (Failed(Condition1))
>
> do_return;
>
> Code_to_execute;
>
> }
>
>
>
> You can even 'do':
>
>
>
> if (do {
>
> if (Failed(Condition0))
>
> do_return false;
>
> if (Succeeded(ConditionShortCut))
>
> do_return true;
>
> if (Failed(Condition1))
>
> do_return false;
>
> return true;
>
> })
>
> Code_to_execute;
>
>
>
> do blocks are compatible with return, break, continue, throw, co_return,
> etc. (and to some degree goto)
>
>
>
> (*do_return* is currently planned instead of *do return*).
>
>
>
>
> -----Ursprüngliche Nachricht-----
> *Von:* LUCE Jean-Sébastien via Std-Proposals <
> std-proposals_at_[hidden]>
> *Gesendet:* Mi 24.05.2023 14:58
> *Betreff:* [std-proposals] "once" keyword
> *An:* std-proposals_at_[hidden];
> *CC:* LUCE Jean-Sébastien <jseb.luce_at_[hidden]>;
> Hello
>
> It is often useful to support multiple cancel conditions, like 'return' in
> a function, but without having to isolate the code in such a function
> (which is called from a single point).
>
> I'm used to write code like
>
> "
> do {
> if (Failed(Condition0))
> break;
> if (Failed(Condition1))
> break;
> Code_to_execute;
> } while (0);
> "
> or
>
> "
> while (Condition0) {
> if (Failed(Condition1))
> break;
> Code_to_execute;
> break;
> };
> "
>
> the example above looks trivial and could be replaced by
> if (Succeeded(Condition0) && Succeeded(Condition1)) {
> Code_to_execute;
> }
>
> Yet with more complex condition codes, writing conditions per line is way
> more readable.
>
> The syntaxe is still "hacked" someway, since "continue" could be used
> wrongly, or final "break" may be forgotten.
>
> I would like "once" behave like do { } while(0);, where only "break" (and
> not "continue") would have a meaning.
>
> for example above could be converted as
> "
> once {
> if (Failed(Condition0))
> break;
> if (Failed(Condition1))
> break;
> Code_to_execute;
> }
> "
>
> "
> once (Condition0) {
> if (Failed(Condition1))
> break;
> Code_to_execute;
> }
> "
>
> "once" could be followed or not by a first condition.
>
> Thanks
>
> --
> 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 2023-05-24 16:49:46