From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-11-12 11:57:15
On 2019-11-12 13:32, Hans Dembinski via Boost wrote:
>> I don't like this syntax, it is awkward and making the code less readable.
>> 1) You are replacing a normal switch, which may be limited in its abilities but is well known even to beginners with something that has a rather unintuitive syntax. The shift operators are associated to streaming in C++ these days, but you use them differently here. Someone who reads this code who is not familiar with eswitch will not immediately understand this. Why did you chose operator>> instead of operator<< ? I think the choice is arbitrary and therefore hard to remember.
>> 2) Your syntax requires one to type a lot of characters. I don't think one should replace the switch but if one did, the following syntax would be more economic and easier to remember, because it is less arbitrary
>> eswitch( value, case(match1), lambda1, case(match2), lambda2 , â¦ , default(), lambdaN );
> PS: I forgot to replace `case` by `case_` and `default` by `default_` but you get the idea.
On the topic of better syntax, there are a few examples in Boost:
Though, I'm not convinced about the usefulness of the proposed eswitch
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk