| Newsgroups |
gmane.comp.lang.io |
| Message-ID |
<[email protected]> |
Ask yourself the following question:
How do I get a method and how do I get a block activated?
Cheers Jan
Spoiler-----------------
b:=block("hi" println)
b call
>hi
m:=method("hi" println)
m
>hi
Sent from my HTC
----- Reply message -----
From: "McCarrell, Jeff" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Io] curiousity: evaluation of block vs. method
Date: Thu, Jun 16, 2011 23:38
Hey everyone. I have been getting to know Io; trying to work out the evaluation rules, especially the difference between a block and a method.
I understand the lexical vs. dynamic binding of variables aspect.
I have read that blocks and methods are mostly the same.
However, there is an aspect of the evaluation rules I am not following.
I would expect this code:
b := block(n,
"in b" println)
b type println
m := method(n,
"in m" println)
m type println
to produce
Block
Method
or perhaps:
Block
Block
Instead, it produces:
Io> doFile("curiousity.io")
Block
in m
Sequence
So it appears that in evaluating:
b type println
b (a block) is not evaluated. This is what I expect. However, for m, a method, it appears m is evaluated, as shown by the "in m" output, and the return type.
This puzzles me.
Asking the Lobby for the named slots back produces more expected results:
Io> Lobby getSlot("m") type
==> Block
Io> Lobby getSlot("b") type
==> Block
So why does evaluating m and b differ so much?
Thanks,
-- jeff