What does 'scope' mean for non-class types?
Don
nospam at nospam.com
Sat May 29 23:15:50 PDT 2010
div0 wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Lars T. Kyllingstad wrote:
>> In D2, what is the effect (if any) of 'scope' in the following situations?
>>
>> scope int a;
>
> Nothing
>
>> struct B { ... }
>> scope B b;
>
> Nothing, B's destructor will be called even without scope.
>
>> scope int[] c;
>
> c gets deleted when the scope ends. this applies to classes as well.
>
>> // According to the spec, 'in' is shorthand for 'const scope'.
>> void foo(in char[] d) { ... }
>
> d is const (read only).
> I've no idea why scope is mentioned, it's meaningless in the context
> of function arguments.
I think in one of the early, complicated versions of the const system,
it meant something. Looks like this mention of it was accidentally left
in the spec.
More information about the Digitalmars-d-learn
mailing list