list vs tuple
Kragen Sitaker
kragen at dnaco.net
Sun Apr 1 22:19:58 EDT 2001
In article <71q9ct4le63anefmiajj5cbh3mg04qu1ga at 4ax.com>,
Michael Prager <Mike.Prager at noaa.gov> wrote:
>If the object is mutable, the difference is quite important, in
>that modifying later what's pointed to by name "b" can also
>modify what's pointed to by name "a".
>
>That behavior is not in agreement with the "mental model" used
>by many other languages, so I would think it a major pitfall for
>beginners -- at least, it was for this beginner.
There are several options in designing a programming language to deal
with this:
- don't allow complex aggregate data structures (like old BASIC and old
FORTRAN)
- forbid mutation (what pure functional languages do)
- allow aliasing (what Python and most real programming languages do)
- always deep-copy or copy-on-write them (like Henry Baker's Linear Lisp)
Are you asserting that Linear Lisp is a more typical language than
Python? What other langauges are you thinking of that take the Linear
Lisp approach?
>it's important enough to be mentioned pretty close to Page 1,
>and in practical terms understandable by those more interested
>in getting work done than in semantics of programming languages
>as an independent field.
I agree --- aliasing is a pain for novice programmers, and an
occasional pitfall for even the most experienced. SICP organizes an
excellent entire two-semester programming textbook around different
ways of managing state and time.
--
<kragen at pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we possess
ourselves.
-- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI]
More information about the Python-list
mailing list