Dumb idea?

P

Peter Hunt

Hi everyone -

I like playing around with language syntax and semantics. I'm thinking
about pulling down the PyPy code and messing around to see what I can
accomplish. My first idea is most succinctly described by example:

class IBlockProtocol:
def __block__(self, func):
# NO RETURN VALUES!
pass

# my_IBlockProtocol is an expression that evaluates to an implementor
of IBlockProtocol

my_IBlockProtocol: expr

# becomes:

my_IBlockProtocol.__block__(lambda: expr)

###

my_IBlockProtocol<param1, paramN>: expr

# becomes:

my_IBlockProtocol.__block__(lambda param1, paramN: expr)

###

my_IBlockProtocol:
stmt1
stmt2

# becomes:

def anon():
stmt1
stmt2

my_IBlockProtocol.__block__(anon)

###

my_IBlockProtocol<param1, paramN>:
stmt1
stmt2

# becomes:

def anon(param1, paramN):
stmt1
stmt2

my_IBlockProtocol.__block__(anon)

###############

Has this already been done? Is it a stupid idea? I think it could be
used to simplify event handling and some Twisted stuff. I'm mainly
looking for reasons why I _wouldn't_ want to take the time to get my
hands dirty with the PyPy code (or even CPython) and try to implement
this syntax.

Thanks.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,175
Messages
2,570,942
Members
47,489
Latest member
BrigidaD91

Latest Threads

Top