C++ pattern matching is coming

Araq rumpf_a at web.de
Tue Oct 25 06:40:01 UTC 2022


On Monday, 24 October 2022 at 20:38:59 UTC, Walter Bright wrote:
> It seems you're suggesting attaching this behavior to the 
> pointer, rather than the function. That means multiple pointer 
> types.
>
> Multiple pointer types have been tried many times. They are 
> attractive in theory, but work out poorly in practice. For 
> example, take:
>
>     char* strcpy(char* dst, char* src);
>
> With two pointer types, now you have 4 implementations of 
> strcpy rather than one. It does not scale.

1. Nobody should care about strcpy in 2022. It was a poor design 
back then and now it's ridiculously foolish.
2. You already have multiple pointer types in D, there is const*, 
immutable*, scope*... It's just that these multiple pointer types 
still don't get the job done because these don't deal with 
ownership nor memory regions effectively.
3. What does not scale is reason by analogy. "In DOS there were 
NEAR and FAR pointers so having multiple pointer types does not 
work so let's conflate traced and untraced pointers." No 
mainstream language that came after D copied this brilliant 
design of yours, maybe it's time to wonder *why*.


More information about the Digitalmars-d mailing list