Deterministic life-time storage type
Artur Skawina
art.08.09 at gmail.com
Sat Apr 21 17:26:38 PDT 2012
On 04/22/12 02:01, Christophe wrote:
> 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.
Yes. there was a reason for my lets-ignore-enforcement-for-now suggestion...
The compiler won't catch the escaping refs right now.
>> 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 ?
It is, or at least this is how i read "references in the parameter cannot be escaped".
It just isn't currently enforced.
artur
More information about the Digitalmars-d
mailing list