On Wednesday, 17 August 2016 at 07:04:26 UTC, Mike wrote:
Or perhaps DIP1000 changes the current behavior of the `scope`
storage class.
My understanding is that the `scope` storage class currently
allocates a class on the stack (though its usage for this
purpose is deprecated in favor of std.typecons.scoped). If
DIP1000 is implemented, it will change that behavior, so the
allocation will instead be on the GC heap, but the compiler
will do some flow-control analysis to prevent escaping
references. Is that right?
I may have found my answer in the DIP, but there is some
ambiguity:
"Currently, scope is ignored except that a new class use to
initialize a scope variable allocates the class instance on the
stack. Fortunately, this can work with this new proposal, with an
optimization that recognizes that if a new class is unique, and
assigned to a scope variable, then that instance can be placed on
the stack."
"can be placed on the stack", or "will be placed on the stack"?
And only "if the new class is unique"? I'm assuming unique mean
a new instance with a reference count (for lack of a better word)
no greater than 1.
Mike