A question on modification of a list via a function invocation

Gregory Ewing greg.ewing at canterbury.ac.nz
Wed Sep 6 04:52:13 EDT 2017


Steve D'Aprano wrote:
> No, they aren't first-class.

Maybe not fully, but you can do a lot more with them
than you can in Pascal or Modula-2.

> - Containers of references are not allowed.

You can't have arrays of references, but struct and class
members can be references, so you can certainly build data
structures that contain them.

(A quick experiment suggests that you can even have arrays
of structs that contain references, so I'm not sure why
they're not allowed in arrays directly.)

> - Once a reference to an object is created, it cannot be changed to 
>   reference another object ("to be reseated").

Actually there is a way to do that, but you have to be
sneaky about it.

Greg



More information about the Python-list mailing list