Xavier Noria
9/29/2007 10:03:00 AM
On Sep 29, 2007, at 11:37 AM, Robert Dober wrote:
> On 9/29/07, David A. Black <dblack@rubypal.com> wrote:
>> Hi --
>>
>> On Sat, 29 Sep 2007, Phlip wrote:
>>
>>> SpringFlowers AutumnMoon wrote:
>>>
>>>> (and in Ruby, we call a method by "pass by value, the value
>>>> being the
>>>> reference (pointer) to an object). and when the method returns
>>>> something, it returns a value, which is the reference to an
>>>> object.) It
>>>> is very consistent all the way. In Ruby, we don't have the "alias
>>>> reference", right?
>>>
>>> In Ruby, types that can (generally) fit into 32 bits are "immediate
>>> types". These Fixnums and Floats are pass-by-value. All other
>>> types -
>>> from String up - are pass by reference:
>>
>> I'd describe it more as SpringFlowers did: pass by value, where the
>> value happens to be a reference.
> Completely agruee with that. IIRC this discussion has been there quite
> a while ago and general agreement was not reached on it.
That's the way it is described in Java as well, Java is pass-by-
value, you pass references by value. C is pass-by-value as well, when
you modify something through a pointer you are passing a pointer by
value.
Perl on the other hand is pass-by-reference:
$ perl -wle '$a = 0; sub { $_[0] = 1 }->($a); print $a'
1
-- fxn