C++ pattern matching is coming

Nick Treleaven nick at geany.org
Fri Oct 28 14:43:54 UTC 2022


On Friday, 28 October 2022 at 12:36:48 UTC, ryuukk_ wrote:
> On Friday, 28 October 2022 at 12:34:42 UTC, ryuukk_ wrote:
>> On Friday, 28 October 2022 at 09:35:06 UTC, Sergey wrote:
>>> On Thursday, 27 October 2022 at 15:14:30 UTC, ryuukk_ wrote:
>>>> PHP also got builtin sumtype and pattern matching
>>>>
>>>> https://laravel-news.com/modern-php-features-explained
>>>>
>>>> https://news.ycombinator.com/item?id=33357318
>>>>
>>>>
>>>> D lagging behind most languages now :/

PHP is hardly a competitor to D.

>>> D also has them: 
>>> https://dlang.org/phobos/std_sumtype.html#match
>>
>> std.sumtype is buggy, it's slow and it is a template
>>
>> C/C++ also had them with MACROs, why do you think they decided 
>> to now have them has built in feature?

Has C or C++ actually added sum types to their standards?

> Only with D the solution is a template, then your program takes 
> 30 seconds to compile and people wonder why it is slow, don't 
> put the burden on the users for something this essential, it 
> doesn't look good

D templates are fast, unlike in C++. Maybe you're using other 
features like CTFE slowing things down. Or maybe the front end 
isn't using GC and you're short on memory. Either way doesn't 
seem like a fundamental criticism of std.sumtype, though they may 
exist.


More information about the Digitalmars-d mailing list