Gerald Vim wrote in post #1127177:
> This is not what Perl does at all.

This conversation has gone on quite a bit.  It started out like "I don't
know why this happens this way" and there were some attempts at
explaining it, but now it's a lot more like "I want it to work like
Perl" and a bunch of ruby-evangelistic responses.

If you want it to do what Perl does, use Perl.  Perl does Perl better
than Ruby.

> Perl retains the passed reference unless
> modified. Not so in Ruby where y becomes
> a new copy as soon as it is mutated.

You need to be really careful when using words like "reference" and
"copy" and "mutated" that you are using them in the context of the
language.

  ### START OF SCRIPT:
  our $SCOPE_0_VARIABLES = {};

  # x = 1;
  my $x_object = new Fixnum(1);
  $SCOPE_0_VARIABLES->{x} = \$x_object;

  # def foo x
  #   x = x + 1
  # end
  our $SCOPE_foo_VARIABLES = {x=>undef}; # variables in scope
  our $SCOPE_foo_FINAL_VALUE = undef; # return value

  #y = foo x
  $SCOPE_foo_VARIABLES->{x} = $SCOPE_0_VARIABLES->{x};
          # copy outer-x to inner-x
  ### IN SUBROUTINE:
  # x = x + 1
  my $intermediate_value = $($SCOPE_foo_VARIABLES->{x}) + 1; # x + 1
  $SCOPE_foo_VARIABLES->{x} = \$intermediate_value; # x = ...
  $SCOPE_foo_FINAL_VALUE = $SCOPE_foo_VARIABLES->{x}; # return value
  ### IN OUTER SCOPE:
  $SCOPE_0_VARIABLES->{y} = $SCOPE_foo_FINAL_VALUE; # y = ...

There is no x.

Apologies if my perl is bad, I can never remember when to use % or -> or
\.

-- 
Posted via http://www.ruby-forum.com/.