[Edu-sig] How does Python do Pointers?

David MacQuigg macquigg at ece.arizona.edu
Tue May 6 16:45:20 CEST 2008


I agree, there is no reason to dig into call-by-??? terminology with new "untainted" programmers.  The sticky-note analogy is all we need for these students.  The figures in Michael's book are excellent.

However, having been tainted by C, I am finding the discussion interesting.  I just don't understand why there is so much confusion with these call-by terms.  Does the function get a copy of the object or a reference to the original object?  It's got to be one or the other.

At 10:11 PM 5/5/2008 -0500, Michael H.Goldwasser wrote:

>  Python's model is quite clean, it just doesn't match up perfectly
>  with the standard call-by-??? terminology.

In call-by-reference evaluation, a function receives an implicit reference to the argument, rather than a copy of its value.
-- http://en.wikipedia.org/wiki/Call_by_value

By this definition, Python's model is call-by-reference, even though the reference (pointer) is not seen by the user.  C's model is call-by-value, even though that value can be an explicitly-evaluated address (pointer).

-- Dave




More information about the Edu-sig mailing list