Guide to the python interp. source?

Fearless Freep joconnor at cybermesa.com
Mon Jul 29 12:51:28 EDT 2002


Michael Hudson <mwh at python.net> wrote in message news:<lkn0saj2ly.fsf at pc150.maths.bris.ac.uk>...

> > > > Things I want to change is for example, everything should be "call by
> > > > refferense",
> > > That may be very hard.  If you want things like this:
> > >
> > > def f(x):
> > >     x += 1
> > >
> > > i = 2
> > > f(i)
> > > i --> 3
> > >
> > > then you have problems.
> > 
> > That is exactly what I want to have, that is more intuitive I think and I
> > don't think it must be that hard either.
> 
> I don't want to get into an argument with you -- but you're wrong ;-)
> 
> Have a look at this page I wrote a while's back:
> 
>     http://starship.python.net/crew/mwh/hacks/objectthink.html
> 
> which explains how Python's object work -- I don't think you can make
> call by reference work without changing this model, and then you don't
> have Python any more.
> 
> FWIW, the way Python objects work is very similar to Lisp and Scheme
> (and just similar to Java).


I was making the argument a few days ago that the inability to do just
that was why Python was more scalable than TCL.

The problem when you have something like

foo (x)

where x can be reassigned as above, is that you can have unintended
consquences.

if you have code like

foo(x)
print x

and x does not come out with the value you expect, you know that it
was not changed in foo(), so you don't have to investigate the
implementation of foo() to determine if it changed x

x = foo(x)  It's obvious you are changing x
y = foo(x)  It's obvious you are not changing x

if you allow

def foo(i)
   i = i + 1

then you lose the ability to look at the clients of foo() and know
what potential consequences there are.

I think Ada got it right with the "in", "out" and "in out" parameter
declarations; short of that, I don't think you should be able to
re-assign parameters to functions, it add complexity to reading and
deciphering code


Take care,
Jay O'Connor
http://www.r4h.org/r4hsoftware



More information about the Python-list mailing list