Some language proposals.

Antoon Pardon apardon at forel.vub.ac.be
Fri Feb 27 03:49:04 EST 2004


Op 2004-02-25, Anton Vredegoor schreef <anton at vredegoor.doge.nl>:
> Antoon Pardon <apardon at forel.vub.ac.be> wrote:
>
>>I don't see much difference between a function changing a higher up
>>variable that is global or just in between.
>
> If you want a function with its own namespace, that is already
> possible as you showed yourself in an earlier post. On the other hand,
> if a function has its own namespace what is the difference between a
> function and a class? Why not use a class in the first place?

Maybe because somtimes it is more easy or natural to think
of a problems in terms of a function and sometimes in terms
of a 

> Remember that "global" is just a way for a function to tell the
> interpreter that this variable belongs to the global namespace. 
>
> There is some inconsistency if one has a function inside a function
> and that function has a global 'x' but the outer function doesn't have
> a global 'x'. Modifications of 'x' from the deepest function do not
> reach the global namespace, in fact they do not even reach the
> namespace of the containing function.
>
> Only if both functions have a global 'x' the name is visible at the
> global and intermediate level. 

Well that looks like either poor design or poor implementation to
me.

> However there is already a mechanism to solve these kind of problems:
> namespaces! Why not use them?

Maybe because that solution can sometimes seem forced onto the
problem. Like if all you have is carpenting tools you only
can provide carpenting solutions.

>
>>>   a,b = A.a,A.b
>>
>>Well maybe my wording was off, but this doesn't accomplisch what I
>>want since after your statement followed by: a = new_value; A.a will
>>not be changed.

Aaargh!!!!, A dreadfull type on my part that completly changed the
meaning of what I wanteds to say. "not" should read "now"

-- 
Antoon Pardon



More information about the Python-list mailing list