binding a reference to a variable

Bengt Richter bokr at oz.net
Wed Apr 10 16:40:15 EDT 2002


On Wed, 10 Apr 2002 15:52:23 GMT, Andrew Koenig <ark at research.att.com> wrote:

>Greg> Andrew Koenig (ark at research.att.com) wrote:
>
>Greg> : My motivation is to be able to write something that is analogous
>Greg> : to call-by-reference in C++.
>
>Greg> *Not* having call-by-reference means that you can read code without
>Greg> wondering whether a particular function call is or is not by reference.  I
>Greg> consider this a blessing, and I'd like to think that the developers of
>Greg> Lisp, C, Java, and Python feel the same way.
>
>Of course, C arrays behave as if they are pass-by-reference
>(only!), even though we both know that's not strictly true
>under the skin.
>
>Anyway, I would be quite content even if the references were
>explicit at the point of call, which would meet your objection.
>And there is even a straightforward way to achieve that state
>now:  Pass a pair of get/set functions instead of the variable
>itself.
>
>So in fact there is a way to do what I want; it's just that it's
>more verbose than I'd like.
>
What about x() as the spelling of get-x's-value and x(v) as the
spelling of set-x's-value-to-v-and-return-v?

That's what I suggested in my other post. I.e., the get/set pair
is implemented by the __call__ method, for conciseness.

Regards,
Bengt Richter



More information about the Python-list mailing list