By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,714 Members | 750 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,714 IT Pros & Developers. It's quick & easy.

Dumb idea?

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2008-06-10, Peter Hunt <fl*********@gmail.comwrote:
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
You have lost me here.
What is this supposed to be doing? To me you introduce a new magic __block__
function in a class that does nothing.

And then you go on and on with implementation details and mappings of some
BlockProtocol to other syntax without an explanation of what you are blocking
(in English text), or what you aim to achieve by blocking.

In other words, your post is to me the same as

class A(object):
def q(self, t):
# do nothing
pass

and the question "did anybody invent q_protocol" already?

Your guess is as good as mine (and probably better since you have a semantics
for the blocking protocol in the back of your mind).
Sincerely,
Albert
Jun 27 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.