Pattern matching in C++ and D
Francesco Mecca
me at francescomecca.eu
Wed Jan 8 12:12:06 UTC 2020
On Tuesday, 7 January 2020 at 17:06:30 UTC, IGotD- wrote:
> On Tuesday, 7 January 2020 at 14:00:01 UTC, Francesco Mecca
> wrote:
>> I found a paper regarding a proposal for pattern matching in
>> C++ on HN a few days ago:
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1371r1.pdf
>>
>> ```
>> let function_with_side_effects x = ...
>> let match x = match x with
>> | p1 -> e1
>> | p2 when function_with_side_effects x -> e2
>> | _ -> e3
>> ```
>
> Doesn't the real benefit first kick in when the statement is an
> expression always returning a value like in your example?
>
> Neither C++ or D has that.
Yes, but that should be possibile in D, isn't it?
More information about the Digitalmars-d
mailing list