On Thursday, 4 December 2014 at 09:25:11 UTC, Walter Bright wrote:
http://wiki.dlang.org/DIP69

Despite its length, this is a fairly simple proposal. It adds the missing semantics for the 'scope' storage class in order to make it possible to pass a reference to a function without it being possible for it to escape.

This, among other things, makes a ref counting type practical. It also makes it more practical to use other storage allocation schemes than garbage collection.

It does not make scope into a type constructor, nor a general type-annotation system.

It does not provide an ownership system, though it would complement one.

So as mentioned, there are various problem with this DIP :
- rvalue are defined as having a scope that goes to the end of the statement. That mean they can never be assigned to anything as per spec. - It add more special casing with & (as if it wasn't enough of a mess with @property, optional () and the fact the function aren't first class). For instance *e has infinite lifetime when &(*e) is lifetime(e).

Also, considering *e has infinite lifetime, (but not e[i] ???) what is the point of scope at all ? If all indirection goes to infinite lifetime (ie GC) then lifetime only apply to local variable and it should not be able to escape these, scope or not.

During discussion, I proposed to differentiate lifetime calculation between lvalues and rvalues (which are inherently different beasts with different lifetime) and carry (or not) the scope flag with each expression.

Reply via email to