Code Blocks

Pupeno pupeno at pupeno.com
Tue Aug 31 19:32:04 PDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday August 31 2004 19:25, Ken Causey wrote:
> On Tue, 2004-08-31 at 17:09, Pupeno wrote:
> > I don't quite agree with this example, if we replace one block in the
> > other we have:
> > _ at lobby executeExampleBlock: aBlock
> > [  | testValue |
> >    testValue: 5.
> >    [ | testValue |
> >       testValue: 3.
> >      ^ [Console ; (testValue as: String) ; '\n']
> >    ]. do.
> > ].
> > which obviusly leads to 3 being printed, BUT, that example gives me the
> > clue, the example should be:
>
> But that's not what my example evaluates to.
>
> generateSampleBlock is not passed to executeExampleBlock in that case.
> It is evaluated and the block is returned.  And that returned block is
> passed to executeExampleBlock.  At least I think that's the case.  Let's
> test it.  Redefine generateExampleBlock like so:
>
> _ at lobby generateExampleBlock
> [ | testValue |
>   testValue: 3.
>   Console ; 'At definition time\n'.
>   ^ [Console ; (testValue as: String) ; '\n']
> ].
>
> Repeated for clarity:
>
> _ at lobby executeExampleBlock: aBlock
> [  | testValue |
>   testValue: 5.
>   aBlock do.
> ].
>
> And now let's execute the test a little differently.
>
> Slate 9> addSlot: #testBlock.
> (Mixins . Types . VM . prototypes .
>  testBlock . globals . traits )
> Slate 10> testBlock: generateExampleBlock.
> At definition time
> []
> Slate 11> executeExampleBlock: testBlock.
> 3
> Nil
>
> I have to admit that I'm not sure how to test my theory above that in
> the original example generateExampleBlock is executed and not passed.
> But anyway this example is better I guess.
Yes, it is indeed better. This thing of managing code block as objects 
sometimes scapes from the way of thinking of a 'legacy-languages' programmer. 
Thanks.

> Your example below is fine as well.
Maybe a mix of both (to be really 'educative').
- -- 
Pupeno: pupeno at pupeno.com - http://www.pupeno.com

PS: Mails that are sent to me and cced to the list, I only got the once, is 
there some kind of problem or is it me ? Furthermore, in the mails I get, the 
List-id is not set.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBNTSnfW48a9PWGkURAj5KAJ9xqsDuoGgSuQEnEJUb2VVBkhEXdgCeK7oE
5fiXkvZPOSDXo70BFXH3nEM=
=6l3K
-----END PGP SIGNATURE-----




More information about the Slate mailing list