Code blocks

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Fri Oct 17 04:21:08 EDT 2003


On Mon, 13 Oct 2003 16:31:27 -0400, rumours say that mertz at gnosis.cx
(David Mertz) might have written:

>I think that codeblocks, a la Ruby, Smalltalk, xBase, would be kinda
>nice to have.  But the thing I like about them isn't really that they
>can be inlined, but rather simply that the operate without defining a
>new (nested) scope.  Basically, codeblocks just amount to
>boilerplate--except possibly paramaterized... and shorter, of course.

I had such an idea too, perhaps could be useful.

The definition syntax I imagined was:
    <block_name>:
        # do something here
        pass

and running the code block was:
    <block_name>

that is, without the colon at the end.
No scopes added, just a kind of code compilation and 'exec' use with
syntactic sugar, so they could represent plain code objects.
The block names are definitely local in a function (so the code snippet
/ block could do LOAD_FAST for the local variables it references), and
no arguments would be allowed.

That was my idea, but parts of it can be changed.

For more info about implementation proposal, see:
http://groups.google.com/groups?selm=5j6v4vc3hcm1k8ugrcdddj9qesf5vl4g97%404ax.com
-- 
TZOTZIOY, I speak England very best,
Ils sont fous ces Redmontains! --Harddix




More information about the Python-list mailing list