From: Gregory Brown Date: 2007-08-14T00:06:53+09:00 Subject: Re: global_variable_set (like instance_variable_set) On 8/13/07, Thomas Hafner wrote: > "Gregory Brown" wrote/schrieb : > > > On 8/12/07, Thomas Hafner wrote: > > > "Gregory Brown" wrote/schrieb : > > > > > > Nevertheless, if Ruby had explicit references (does it?), it would be > > > simple enough to have just one function instead of the original both > > > ones > > > > You'll want to catch up on this thread: > > http://rubyurl.com/FrJ > > This thread treats ``pass by reference'' which is like aliasing. With > ``explicit references'' I rather mean explicitly referencing (by > operator ``&'' in C resp. ``\'' in Perl) and dereferencing (by > operator ``*'' in C resp. ``$'' in Perl). Here's a Perl example: > > sub foo { > my ($ref) = @_; # consume argument array > ${$ref}++; # dereference and increment > } > my $bar = 3; > foo(\$bar); # make a reference to $bar and pass it to the function > print $bar; # => 4 Sure, but it's the same idea. You're trying to change the binding of $bar from a different scope -greg