[Python-Dev] anonymous blocks

Josiah Carlson jcarlson at uci.edu
Wed Apr 20 06:39:32 CEST 2005

Michael Walter <michael.walter at gmail.com> wrote:
> On 4/19/05, BJörn Lindqvist <bjourne at gmail.com> wrote:
> > > RSMotD (random stupid musing of the day): so I wonder if the decorator
> > > syntax couldn't be extended for this kind of thing.
> > >
> > > @acquire(myLock):
> > >     code
> > >     code
> > >     code
> > 
> > Would it be useful for anything other than mutex-locking? And wouldn't
> > it be better to make a function of the block wrapped in a
> > block-decorator and then use a normal decorator?
> Yes. Check how blocks in Smalltalk and Ruby are used for starters.

See the previous two discussions on thunks here on python-dev, and
notice how the only problem that seem bettered via blocks/thunks /in
Python/ are those which are of the form...


... and depending on the syntax, properties.  I once asked "Any other
use cases for one of the most powerful features of Ruby, in Python?"  I
have yet to hear any sort of reasonable response.

Why am I getting no response to my question?  Either it is because I am
being ignored, or no one has taken the time to translate one of these
'killer features' from Smalltalk or Ruby, or perhaps such translations
show that there is a better way in Python already.

Now, don't get me wrong, I have more than a few examples of the
try/finally block in my code, so I would personally find it useful, but
just because this one pattern is made easier, doesn't mean that it
should see syntax.

 - Josiah

P.S. If I'm sounding like a broken record to you, don't be surprised. 
But until my one question is satisfactorally answered, I'll keep poking
at its soft underbelly.

More information about the Python-Dev mailing list