Re: High Order Messages in Python

2005-10-24 Thread Kent Johnson
[EMAIL PROTECTED] wrote: counting that out(regardless whether it is (dis)advantage or not), what else a block can do but not a named function ? My limited understanding is that the advantage is - simpler syntax - high level of integration into the standard library (*many* methods that take

Re: High Order Messages in Python

2005-10-24 Thread [EMAIL PROTECTED]
thanks. Seems that my programs are very simple and don't need these feature yet. Kent Johnson wrote: [EMAIL PROTECTED] wrote: counting that out(regardless whether it is (dis)advantage or not), what else a block can do but not a named function ? My limited understanding is that the

Re: High Order Messages in Python

2005-10-24 Thread Alex Martelli
Kent Johnson [EMAIL PROTECTED] wrote: ... For example to open a file and read from it uses two closures, one to wrap a block with the file open/close, one to iterate lines (from the pickaxe book): File.open(testfile) do |file| file.each_line { |line| puts line } end Good example --

Re: High Order Messages in Python

2005-10-23 Thread Michael
[EMAIL PROTECTED] wrote: I'm reading about high order messages in Ruby by Nat Pryce, and thinking if it could be util and if so, if it could be done in Python. Nice sunday afternoon exercise. Yes, you can do this in python. This is based on a relatively naive translation of the ruby version:

Re: High Order Messages in Python

2005-10-23 Thread vdrab
On a (somewhat) related note, I've always wondered whether it is possible to emulate ruby blocks using a python generator '+ alpha'. In my limited understanding of the ruby block, the generator can inject values into a block, I suppose, but what is the block itself? can it be a function? a class

Re: High Order Messages in Python

2005-10-23 Thread gene tani
http://www.artima.com/intv/closures.html http://www.rubyist.net/~matz/slides/oscon2005/index.html It's a read-write closure, a co-routine, sort of a continuation (tho Kernel.callcc is considered the real continuation mechanism). And you can make it a Proc object (basically an unbound object you

Re: High Order Messages in Python

2005-10-23 Thread [EMAIL PROTECTED]
could someone enlighten me what is the advantage of block over named function ? One thing that I can see a difference may be lexical scope ? vdrab wrote: On a (somewhat) related note, I've always wondered whether it is possible to emulate ruby blocks using a python generator '+ alpha'. In my

Re: High Order Messages in Python

2005-10-23 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: could someone enlighten me what is the advantage of block over named function ? One thing that I can see a difference may be lexical scope ? Yes, but -- according to the latest Ruby book, the mixed lexical scope of blocks is a highly controversial

Re: High Order Messages in Python

2005-10-23 Thread [EMAIL PROTECTED]
counting that out(regardless whether it is (dis)advantage or not), what else a block can do but not a named function ? Alex Martelli wrote: [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: could someone enlighten me what is the advantage of block over named function ? One thing that I can see

High Order Messages in Python

2005-10-22 Thread [EMAIL PROTECTED]
I'm reading about high order messages in Ruby by Nat Pryce, and thinking if it could be util and if so, if it could be done in Python. Someone already tried? References: http://lambda-the-ultimate.org/node/view/1047 http://nat.truemesh.com/archives/000535.html

Re: High Order Messages in Python

2005-10-22 Thread Jp Calderone
On 22 Oct 2005 14:12:16 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm reading about high order messages in Ruby by Nat Pryce, and thinking if it could be util and if so, if it could be done in Python. Someone already tried? Here's an example of the idea, in Python: def messageA():

Re: High Order Messages in Python

2005-10-22 Thread [EMAIL PROTECTED]
Hum... I thnk you dont get the ideia: I'm not talking abou High Order Functions. What ho call High Order Methods is some like connecting some 'generic' methods created to do things like this: claimants.where.retired?.do.receive_benefit 50 The 2nd and 3rd links that in the first post is the

Re: High Order Messages in Python

2005-10-22 Thread Jp Calderone
On 22 Oct 2005 15:11:39 -0700, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hum... I thnk you dont get the ideia: I'm not talking abou High Order Functions. What ho call High Order Methods is some like connecting some 'generic' methods created to do things like this:

Re: High Order Messages in Python

2005-10-22 Thread Sam Pointon
This can be suitably applied to Python with the use of Higher Order Functions, though. It's not quite the Ruby version because Python allows you to use functions as first-class objects, complicating the All-You-Can-Do-Is-Pass-A-Message philosophy. This is my 5-minute implementation: class

Re: High Order Messages in Python

2005-10-22 Thread Mike Meyer
[EMAIL PROTECTED] [EMAIL PROTECTED] writes: I'm reading about high order messages in Ruby by Nat Pryce, and thinking if it could be util and if so, if it could be done in Python. Someone already tried? Yes, I'm pretty sure it could be done in Python. All it really needs is the ability to