I got an error "Attempt to evaluate a block that is already being evaluated", when I call in recursion a block like
carre := [:s1 :s2 :s3 :s4 :n | n >0 ifTrue: [carre valueWithArguments: {(segment value: s1 value: s2). (segment value: s2 value: s3). (segment value: s3 value: s4). (segment value: s1 value: s4). n-1}]]
Hilaire
You could add an extra parameter that is another block. Use that parameter as the value of carre in the block. something like:
f := [:a :ff | a ifTrue: [ff (a not) ff] ] ff: = [:a :ff | a ifTrue: [ff (a not) ff] ]
On Jan 22, 2008 9:10 PM, Hilaire Fernandes hilaire@ofset.org wrote:
I got an error "Attempt to evaluate a block that is already being evaluated", when I call in recursion a block like
carre := [:s1 :s2 :s3 :s4 :n | n >0 ifTrue: [carre valueWithArguments: {(segment value: s1 value: s2). (segment value: s2 value: s3). (segment value: s3 value: s4). (segment value: s1 value: s4). n-1}]]
Hilaire
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
For the avoidance of confusion, here is a version with non-guessed syntax:
f := [:a :ff | a ifTrue: [{a . (ff value: (a not) value: ff)}] ifFalse: a]. g := [:a :ff | a ifTrue: [{a . (ff value: (a not) value: ff)}] ifFalse: a]. f value: true value: g.
On Jan 22, 2008 9:35 PM, Marcin Tustin mm3@zepler.net wrote:
You could add an extra parameter that is another block. Use that parameter as the value of carre in the block. something like:
f := [:a :ff | a ifTrue: [ff (a not) ff] ] ff: = [:a :ff | a ifTrue: [ff (a not) ff] ]
On Jan 22, 2008 9:10 PM, Hilaire Fernandes hilaire@ofset.org wrote:
I got an error "Attempt to evaluate a block that is already being evaluated", when I call in recursion a block like
carre := [:s1 :s2 :s3 :s4 :n | n >0 ifTrue: [carre valueWithArguments: {(segment value: s1 value: s2). (segment value: s2 value: s3). (segment value: s3 value: s4). (segment value: s1 value: s4). n-1}]]
Hilaire
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
I'm an idiot. That doesn't work either. Why not?
On Jan 22, 2008 10:12 PM, Marcin Tustin mm3@zepler.net wrote:
For the avoidance of confusion, here is a version with non-guessed syntax:
f := [:a :ff | a ifTrue: [{a . (ff value: (a not) value: ff)}] ifFalse: a]. g := [:a :ff | a ifTrue: [{a . (ff value: (a not) value: ff)}] ifFalse: a]. f value: true value: g.
On Jan 22, 2008 9:35 PM, Marcin Tustin mm3@zepler.net wrote:
You could add an extra parameter that is another block. Use that parameter as the value of carre in the block. something like:
f := [:a :ff | a ifTrue: [ff (a not) ff] ] ff: = [:a :ff | a ifTrue: [ff (a not) ff] ]
On Jan 22, 2008 9:10 PM, Hilaire Fernandes hilaire@ofset.org wrote:
I got an error "Attempt to evaluate a block that is already being evaluated", when I call in recursion a block like
carre := [:s1 :s2 :s3 :s4 :n | n >0 ifTrue: [carre valueWithArguments: {(segment value: s1 value: s2). (segment value: s2 value: s3). (segment value: s3 value: s4). (segment value: s1 value: s4). n-1}]]
Hilaire
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
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.
Hilaire
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
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,
On Wed, 23 Jan 2008 18:52:51 +0100, Hilaire Fernandes wrote:
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
Hey, what a nice return for a double clone :-)
Klaus D. Witzel a écrit :
Hi Hilaire,
"Hilaire" == Hilaire Fernandes hilaire@ofset.org writes:
Hilaire> I got an error "Attempt to evaluate a block that is already being evaluated", Hilaire> when I call in recursion a block like
Hilaire> carre := [:s1 :s2 :s3 :s4 :n | Hilaire> n >0 ifTrue: Hilaire> [carre valueWithArguments: {(segment value: s1 value: s2). Hilaire> (segment value: s2 value: s3). Hilaire> (segment value: s3 value: s4). Hilaire> (segment value: s1 value: s4). Hilaire> n-1}]]
This is a maintenance nightmare waiting to happen. Use a proper method call, perhaps creating a "manager" class to manage the workflow, and so you don't have to keep passing segment around.
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
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.
On Jan 22, 2008 11:42 PM, Ben Goetter goetter@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@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
I figured it out - I meant monticello + squeaksource.
Having loaded newcompiler, ast, blockchecker, and newcompilerloader, it doesn't seem to have made a difference.
On Jan 23, 2008 12:00 AM, Marcin Tustin mm3@zepler.net 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.
On Jan 22, 2008 11:42 PM, Ben Goetter goetter@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@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
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@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@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Mth
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
On Jan 22, 2008 9:10 PM, Hilaire Fernandes hilaire@ofset.org wrote:
I got an error "Attempt to evaluate a block that is already being evaluated", when I call in recursion a block...
<snip>
This is a know limitation of Squeak, eg see discussion around http://lists.squeakfoundation.org/pipermail/squeak-dev/2007-December/123421....
Cheers, Michael
(re-sent as my original seems to have wandered off course)
beginners@lists.squeakfoundation.org