Re: [Twisted-Python] regarding callbacks.

2012-04-30 Thread Ivan Kozik
On Mon, Apr 30, 2012 at 20:45, Jasper St. Pierre  wrote:
> Right now, you could implement inlineCallbacks in Mozilla JavaScript.

A few years ago, I confirmed that this actually works:

http://ludios.org/js-inlineCallbacks-POC/

(though the above is inconvenient to use because it relied on my fork
of Divmod's JS).

I think there has been similar work in the node.js world.  I recall
some node.js forks that run on SpiderMonkey just so that they can use
its `yield`.

Ivan

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] regarding callbacks.

2012-04-30 Thread Jasper St. Pierre
On Mon, Apr 30, 2012 at 4:15 PM, Glyph  wrote:
> On Apr 30, 2012, at 4:57 AM, moses dsouza wrote:
>
> I don't think so.  Most of what Guido wants is already available via 
> inlineCallbacks, and the drawbacks of using that are documented pretty well 
> in the comments there.  I also have some issues with the premises and 
> conclusions of that article. For example, batching, pipelining and pooling 
> are all easier to implement with a callback-driven style.
>
> I think that article is mainly about aesthetic choices, and the culture of 
> the Python community.  However, it does highlight the need to document the 
> reasons why things are the way that they are in the Twisted world, so that 
> the broader Python community understands that it's not weird for the sake of 
> weird; but this is a documentation issue.  For example, Node.JS doesn't have 
> this problem, despite having a much worse convention of callback spaghetti 
> (as far as I know, they don't have an abstraction analogous to a Deferred 
> yet); this is because the JavaScript community has already accepted callbacks 
> and is intimately familiar with them before approaching Node for the first 
> time.  There are a few analogues in Python (for example, GUI toolkit 
> programming) but a smaller proportion of the community at large are familiar 
> with that style.

Several large JS toolkits have the concept of a Deferred or a Promise.
MochiKit stole Twisted's, where it got forked into Dojo, and then
forked into Google's Closure library. jQuery has a separate Deferred
implementation that looks like Twisted's, and is similar enough that
we can call it a Deferred, although I know a few people who object to
that.

This is a bit off-topic, but generators are expected to be in Harmony
(they're already in Mozilla's JS, stolen wholesale from Python). The
latest specification draft has "yield" as a future reserved word, and
has a reference to an undefined "YieldExpression", though this may
just be an editing oversight.

Right now, you could implement inlineCallbacks in Mozilla JavaScript.

> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

-- 
  Jasper

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] regarding callbacks.

2012-04-30 Thread Glyph
On Apr 30, 2012, at 4:57 AM, moses dsouza wrote:

> I was reading 
> http://technicae.cogitat.io/2012/03/conversation-with-guido-about-callbacks.html
> . I'm not done with it yet but I'm sure some of you would have already
> read this. Would there be any changes required in Twisted code because
> of the views in this blog ? Or put it in another way, is there
> anything we can take from it that we can use to help make Twisted
> better ?

I don't think so.  Most of what Guido wants is already available via 
inlineCallbacks, and the drawbacks of using that are documented pretty well in 
the comments there.  I also have some issues with the premises and conclusions 
of that article. For example, batching, pipelining and pooling are all easier 
to implement with a callback-driven style.

I think that article is mainly about aesthetic choices, and the culture of the 
Python community.  However, it does highlight the need to document the reasons 
why things are the way that they are in the Twisted world, so that the broader 
Python community understands that it's not weird for the sake of weird; but 
this is a documentation issue.  For example, Node.JS doesn't have this problem, 
despite having a much worse convention of callback spaghetti (as far as I know, 
they don't have an abstraction analogous to a Deferred yet); this is because 
the JavaScript community has already accepted callbacks and is intimately 
familiar with them before approaching Node for the first time.  There are a few 
analogues in Python (for example, GUI toolkit programming) but a smaller 
proportion of the community at large are familiar with that style.

But, if you can think of something actionable that would make Twisted better 
based on that blog post - or anything else, for that matter! - feel free to 
file a ticket.

-glyph


___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] regarding callbacks.

2012-04-30 Thread moses dsouza
Hi Guys

I was reading 
http://technicae.cogitat.io/2012/03/conversation-with-guido-about-callbacks.html
. I'm not done with it yet but I'm sure some of you would have already
read this. Would there be any changes required in Twisted code because
of the views in this blog ? Or put it in another way, is there
anything we can take from it that we can use to help make Twisted
better ?

regards
moijes12

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python