Hi Hilaire,

on Wed, 23 Jan 2008 09:49:07 +0100, you wrote:


Le mardi 22 janvier 2008 à 22:16 +0000, Marcin Tustin a écrit :
I'm an idiot. That doesn't work either. Why not?

Because still nested, I guess.
Anyway I want to use that for teacher to design programmaticaly
interactige geometry figure for Drgeo. So it have to keep simple and be
usable in a Workspace.

The only alternative I see is to define a class with methods, but it is
a bit more complex for the target audiance.

You don't have to. I use recursive blocks in Smalltalk workspace all the time. The "trick" is from the Self language, which always clones activation record before using them. Example:

 recursiveBlock := [:argV |
   argV < 1
    ifFalse: [argV + (recursiveBlock clone value: argV - 1)]
    ifTrue: [argV]].

 recursiveBlock clone value: 17

You could send #copy instead of #clone but I prefer the latter in honor of Self.

Enjoy!

/Klaus

P.S. beware of the #fixTemps symptom in Squeak's implementation of blocks, was discussed several times over in squeak-dev.

Hilaire



_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to