Re: curiousity: evaluation of block vs. method
Oscar Martinez <[email protected]>
| Newsgroups | gmane.comp.lang.io |
|---|---|
| Message-ID | <[email protected]> |
2011/6/19 McCarrell, Jeff <[email protected]> > ** > > > Hey everyone. I have been getting to know Io; trying to work out the > evaluation rules, especially t > he 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 > Hi Jeff, getSlot("m") type println When you do "m type println" you are activating the "m" slot (a method), then "type println" is sent to the value returned by "m" (a Sequence in your example). "b" is not activatable by default. To acivate it you do "b call(<params>)". Also, If you do: "b setIsActivatable(true)", the behaviour will be (AFAIK) the same as "m". Hope that helps :) Regards Oscar ._,___