Deterministic life-time storage type
Christophe
travert at phare.normalesup.org
Sat Apr 21 17:01:59 PDT 2012
Artur Skawina , dans le message (digitalmars.D:164784), a écrit :
> "scope", in its current meaning, should have been the default for all
> function arguments. If this was the case, would introducing your scope-scopes
> bring any additional benefits? (Let's ignore enforcement for now, and assume
> the compiler won't let the scoped variables escape).
Scope in its current meaning is about the same as my scope(in) for
parameters. However, it is not transitive, and that changes a
lot of things:
int[] g;
void foo(scope int[] a) { g = a; } // passes: a is not protected at all
scope is pointless here. It cannot even protect an array. Just like
const/immutable, transitivity is essential.
> Your "scope(out)" seems to be yet another incarnation of uniq/unique
> (something that apparently keeps coming up over and over again).
>
> "scope(inout)" AFAICT could be "T[] f(return T[] a) { return a[0..2];
> }"; reusing the "return" keyword to mean "this argument could be
> returned directly or indirectly as result".
I never heard about uniq or return keyword for parameters. I don't have
time to follow the forum most of the time. So basically I just put those
three ideas together, with a new naming convention, and transitivity.
Why are these ideas not going further ?
Well, I could have summarized my long post in one line:
Why is the scope attribute not transitive ?
--
Christophe
More information about the Digitalmars-d
mailing list