preparing for const, final, and invariant
Manuel König
ManuelK89 at gmx.net
Fri May 18 08:47:10 PDT 2007
Walter Bright wrote:
> Manfred Nowak wrote:
>> Walter Bright wrote
>>
>>> Frank Benoit wrote:
>>>> int[] g;
>>>> void foo(in int[] a){
>>>> g = a.dup; // allowed?
>>>> }
>>> Yes.
>>
>> The `.dup'ing an array where a cell contains a reference to the array
>> is allowed too?
>>
>> alias void* T;
>> T[] a;
>> void main(){
>> T[] g; g.length= 1;
>> g[0]=&g;
>> void f( in T[] p){
>> a= p.dup;
>> }
>> }
>>
>> That would contradict the given rule.
>
> I don't understand. What rule is being violated, and how?
I think he is concerning to the scope rule. When 'f' gets called with
'g' as param, then 'a' has implicitly a reference to 'g', namely in
a[0]. This would be a violation of the scope rule.
-- Regards
Manuel
More information about the Digitalmars-d-announce
mailing list