DIP 36: Rvalue References
Zach the Mystic
reachzach at gggggmail.com
Sun Apr 21 09:02:34 PDT 2013
On Sunday, 21 April 2013 at 02:50:02 UTC, deadalnix wrote:
> If that is your concern then the DIP36 is a very bad answer to
> it :
> - It require extra anotation, which wont be added most of the
> time.
It's possible to make it an error to pass a stack variable to a
non-'scope' ref parameter. Or to make it an error in @safe code
only. But those may be extreme measures. This also raises the
issue that some types of escape are more dangerous than others.
ref T func(ref T a) {
return a; // Escape by return, @safe if tracked at call site
T* p = &a; // Escape to local pointer, @safe? if *p is tracked
static T* s = &a; // Escape by global pointer, @system
}
In this sense, 'scope' is a blunt instrument, because you might
want to say, 'returnable, but not globally assignable'.
'scope' is also the kind of thing which might be better as the
default than as something you must specifically add. But then
we'd need an attribute '@noscope' or something like that. Ugh.
> - It is inferior, and impair the introduction of lifetime.
> This isn't even discussed.
You've mentioned lifetime a couple times. Can you show what
lifetime is and show how it contrasts with the current proposal,
particularly DIP25?
More information about the Digitalmars-d
mailing list