A question on modification of a list via a function invocation

Gregory Ewing greg.ewing at canterbury.ac.nz
Tue Sep 5 09:37:20 EDT 2017


Dennis Lee Bieber wrote:
> 	Pascal, probably Modula-2, Visual BASIC are closer to the C++ reference
> semantics, in that the definition of a function declares how the
> argument(s) are passed.

Well, sort of. In Pascal and Modula, and also VB I think,
parameters are the only things that can be declared as having
reference semantics, whereas references in C++ are first-class
things that can be stored in any variable.

> 	I don't have Java textbooks locally (in storage 15 miles away) but from
> what I recall, it too has the complication of splitting between "simple
> types" and "reference types" ("boxed" I believe is the term used in books).
> The default passing mechanism would be similar to the description of C#
> ("boxed" types being implicit copies of references allowing mutation
> in-place, but assignment to the parameter itself has no effect on the
> caller). I suspect it too has some means to explicitly produce a
> by-reference parameter.

No, Java doesn't have by-reference parameters, which can be
annoying at times when combined with the fact that it doesn't
have anything like Python's easy tuple returning and unpacking.

-- 
Greg




More information about the Python-list mailing list