C++ pattern matching is coming

Paul Backus snarwin at gmail.com
Mon Oct 24 19:12:12 UTC 2022


On Monday, 24 October 2022 at 18:18:52 UTC, Walter Bright wrote:
> There's a misunderstanding here. @live *does* work in @safe 
> code, and confers benefits.
>
[...]
>
> 1. void foo(int* p) => argument is moved to foo(), caller can 
> no longer use it
>
> 2. void foo(scope int* p) => argument is copied to foo(), 
> caller retains ownership

The problem with using @live and @safe together is that (a) you 
cannot *safely* call a @live function from a non- at live function, 
or vice-versa (because non- at live functions will not honor the 
above rules), and (b) as a consequence, changing a function from 
@safe to @safe @live is a breaking API change.

This means that existing @safe D projects will not be able to 
adopt @live, and the community will have to build an entirely new 
@safe @live ecosystem from the ground up in order to see any 
benefit in practice. The more likely outcome is that D users will 
stick with their existing @safe codebases (which they've invested 
time and money in) and ignore @live altogether.

It's a Python 2/Python 3 situation--exactly the kind of thing D 
wants to avoid.

(Of course, projects written in @system D will be free to adopt 
@live--but why would they? If they wanted automatic safety 
checking, they'd already be using @safe.)


More information about the Digitalmars-d mailing list