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 ex
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 ad
[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
cl
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 tha
[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 contr
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 m
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 ca
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 in
[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 versio
"[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 abilit
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 HigherO
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:
>claimants.where.r
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 m
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 messa
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
http://nat.truemesh.com/archives/0
15 matches
Mail list logo