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
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