[Python-Dev] anonymous blocks

Shannon -jj Behrens jjinux at gmail.com
Tue Apr 19 20:35:21 CEST 2005


(I apologize that this is my first post.  Please don't flame me into
oblivion or think I'm a quack!)

Have you guys considered the following syntax for anonymous blocks?  I
think it's possible to parse given Python's existing syntax:

   items.doFoo(
       def (a, b) {
           return a + b
       },
       def (c, d) {
           return c + d
       }
   )

Notice the trick is that there is no name between the def and the "(",
and the ")" is followed by a "{".

I understand that there is hesitance to use "{}".  However, you can
think of this as a Python special case on the same level as using ";"
between statements on a single line.  From that perspective, it's not
inconsistent at all.

Best Regards,
-jj


More information about the Python-Dev mailing list