[Newbies] Re: block in recursion, Any cure for that kind of situation?

2008-01-23 Thread Hilaire Fernandes

Le mardi 22 janvier 2008 à 22:16 +, 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.

Hilaire



signature.asc
Description: Ceci est une partie de message	numériquement signée
___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: block in recursion, Any cure for that kind of situation?

2008-01-23 Thread Hilaire Fernandes
Indeed, and I am adapting from DrGeo1.1 which embede the Guile Scheme
interpretor, see
http://documentation.ofset.org/drgeo/fr/drgenius_93.html

Hilaire

Le mardi 22 janvier 2008 à 15:42 -0800, Ben Goetter a écrit :
 This is a maintenance nightmare waiting to happen.  Use a proper method call,
 
 Squeak Smalltalk blocks are just similar enough to Scheme lambdas that I 
 still fall into this trap, too.
 
 (letrec ((carre (lambda (s1 s2 s3 s4 n)
  (if ( n 0)
   (carre (segment s1 s2)
  (segment s2 s3)
  (segment s3 s4)
  (segment s1 s4)
  (- n 1))
  'oops-must-remember-this-is-Squeak-not-Scheme)
 
 Ben


signature.asc
Description: Ceci est une partie de message	numériquement signée
___
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners


[Newbies] Re: block in recursion, Any cure for that kind of situation?

2008-01-23 Thread Klaus D. Witzel

Hi Hilaire,

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



Le mardi 22 janvier 2008 à 22:16 +, 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


[Newbies] Re: block in recursion, Any cure for that kind of situation?

2008-01-23 Thread Hilaire Fernandes

Hi Klaus,

Thanks for the tip, I also need the fixTemps. It is not very elegant but 
it works. See the vidéo: http://squeak.ofset.org/drgeo/spiral.ogg




Klaus D. Witzel a écrit :

Hi Hilaire,



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