On Sun, 09 Nov 2008 11:17:28 +0000, Arnaud Delobelle wrote: > greg <[EMAIL PROTECTED]> writes: > >> Arnaud Delobelle wrote: >> >>> What's a variable reference? >> >> It's a reference to a variable. It's what gets passed behind the scenes >> when you use a VAR parameter in Pascal, or a ByRef parameter in VB. > > Do you mean you can't do the following C++ snippet in Pascal or VB? I > haven't used Pascal for more than 20 year and I have never used VB, so > this is a real question. > > foo(int &x) { > x = 7; > } > > struct bar { > int i; > float j; > }; > > int main() { > int a[10]; > bar b; > // What is passed to foo below is obviously not a 'variable > // reference' as the argument is not a variable. > foo(a[3]); // Now a[3] == 7 > foo(b.i); // Now b.i == 7 > }
Translated to Pascal: Program Test; Type Bar = Record i: Integer; j: Real; End; Var a: Array[0..9] Of Integer; b: Bar; Procedure Foo(Var x:Integer); Begin x := 7; End; Begin Foo(a[3]); WriteLn(a[3]); {Prints 7.} Foo(b.i); WriteLn(b.i); {Prints 7.} End. In "reality" I would not expect that anything is passed here but that the compiler inlines it as direct assignment. Should read: Copying the bit pattern of a 7 into the fixed memory locations. :-) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list