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

Mathieu Suen mathk.sue at gmail.com
Wed Jan 23 00:26:21 UTC 2008


On Jan 23, 2008, at 1:00 AM, Marcin Tustin wrote:

> So am I right in thinking that if I get newCompiler, blocks will  
> work as I would expect them to (like lambdas)?
>
> If so, how do I get the most recent version? I remember there being  
> something that has superceded squeakmap, but I can't seem to find it.

You can find it on squeaksource.
http://www.squeaksource.com/NewCompiler.html

You first need to load AST NewParser RefactoringEgine and SmaccRuntime.
In other to load them all you could use the NewCompilerLoader  
availible one the NewCompiler squeaksource repository.
Simply invoke:
NewCompilerLoader new loadPackage.

This will recompile the complete image using the NewCompiler.

To avoid the recompilation you can look at the loadPackage method.
You could also load the NewCompiler throw the Universe browser.

After loading the compiler you have 2 way to compile code.

1. Use the NewCompiler but don't make full block closure. (Preference  
browser section compile #compileUseNewCompiler)
	
	In this mode the block still remain the same and temp are share
  	among the home context. That the reason why you could not invoke
	recursively a block.

2. Enable the block closure. (Preference browser section compile  
#compileBlocksAsClosures)

	With this preference the block while be transform in full block  
closure. You could then recursively
	invoke a block. Block while then create a environment  to store temps  
whenever is needed.


HTH
Cheers,


>
>
> On Jan 22, 2008 11:42 PM, Ben Goetter <goetter at mazama.net> wrote:
> >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
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

	Mth





More information about the Beginners mailing list