R
Robert Klemme
I feel there is a subtle point that needs clarification.
Unfortunately the term "reference" does not have an unambiguous
meaning in our field. I know at least these meanings
1. R. is a general term for any programming language construct that
allows to reference a value. This does not sound very involved but
it's actually as simple (or: as general) as that. Unfortunately
this includes things like C pointers, Pascal pointers, C++ references,
Perl references, Ruby references (Matz, is this the proper term?) etc.
2. C++ R. type is a special beast which has some additional properties
compared to 1. This does not only allow to reference a value but in
fact you can say that it references a reference[1]. Or you can say
that a C++ reference is an alias for a variable. Hence it allows to
manipulate a variable in a calling scope.
See also http://en.wikipedia.org/wiki/Reference#Computer_science
Ruby's evaluation strategy is actually "call by reference" although
the description at
http://en.wikipedia.org/wiki/Call_by_reference#Call_by_reference does
not cover Ruby properly - unless you interpret "temporary object" as
"copy of a reference" because this is how it works.
Note: I do not cover special cases like Fixnums here because from the
Ruby programmer's perspective there is no difference in behavior -
just in speed and memory.
Kind regards
robert
Unfortunately the term "reference" does not have an unambiguous
meaning in our field. I know at least these meanings
1. R. is a general term for any programming language construct that
allows to reference a value. This does not sound very involved but
it's actually as simple (or: as general) as that. Unfortunately
this includes things like C pointers, Pascal pointers, C++ references,
Perl references, Ruby references (Matz, is this the proper term?) etc.
2. C++ R. type is a special beast which has some additional properties
compared to 1. This does not only allow to reference a value but in
fact you can say that it references a reference[1]. Or you can say
that a C++ reference is an alias for a variable. Hence it allows to
manipulate a variable in a calling scope.
See also http://en.wikipedia.org/wiki/Reference#Computer_science
Ruby's evaluation strategy is actually "call by reference" although
the description at
http://en.wikipedia.org/wiki/Call_by_reference#Call_by_reference does
not cover Ruby properly - unless you interpret "temporary object" as
"copy of a reference" because this is how it works.
Note: I do not cover special cases like Fixnums here because from the
Ruby programmer's perspective there is no difference in behavior -
just in speed and memory.
Kind regards
robert