469,304 Members | 1,796 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

Dumb idea?

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
1 766
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.

Similar topics

16 posts views Thread by squash | last post: by
2 posts views Thread by Marion | last post: by
3 posts views Thread by ed | last post: by
4 posts views Thread by Piedro | last post: by
4 posts views Thread by ItNerd | last post: by
17 posts views Thread by vashwath | last post: by
3 posts views Thread by rdufour | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.