Parameterized Functions without Classes

Hung Jung Lu hungjunglu at
Tue Jun 29 18:59:00 CEST 2004

Jacek Generowicz <jacek.generowicz at> wrote:
> hungjunglu at (Hung Jung Lu) writes:
> > I have counted 7 messages in the thread, so far. How come no one
> > mentioned the keyword "closure"?
> I was tempted, but realized that this would only lead to me producing
> a combination of my 3 favourite rants, so I refrained.

How about a codeblock-based language that does the following:

f = function( args={x;y;z=g(5);}, deco={synchronized;},
              init={.static=1;}, code={

        w = x+y+z+.static;
        .static += 1;


f(1,2,3) # returns 7
f(1,2,3) # returns 8

(a) "args" codeblock is executed in such a way that each additional
name is used to build up the argument list of the function. (Special
setattr()/setslot() function is used, if you know what I mean.)

(b) "deco" codeblock builds up names to be used for special decorated

(c) "init" codeblock is run only the first time the function is

(d) "code" is the regular codeblock of the function. The return value
is the value of the codeblock, which is the value of the last

(f) functions are self-aware. The "self" name is optional: an initial
dot suffices. This is enough to take of closure needs, I think.

(g) functions are built by using the "function" function. Don't ask me
chicken-and-egg questions.


Hung Jung

More information about the Python-list mailing list