error: 'Attempt to evaluate a block that is already being evaluated.'

Matej Košík kosik at fiit.stuba.sk
Sun Aug 21 21:28:41 UTC 2005


Hello,

I have an interesting question. My friend asked me the following

"(23:03:01) Ján Žiak: I think that the languages I have seen so far 
there is no possibility to mark some part of code with a name and then 
to use this code in some other code. I have stumbled on a situation 
where I would need it --- I would like to call recursively some part of 
method code without the need to put it in a separate method."

I wasn't able to help him right now, but for fun I have tried the following:

    factorial := [:n | n <= 1
                         ifTrue: [1]
                         ifFalse: [n * (factorial value: n - 1)]
                 ].

    factorial value: 1

succeeds, but

    factorial value: 2

ends with
`error: 'Attempt to evaluate a block that is already being evaluated.'

Is there a way how to make the above code to work?
-- 
Matej Košík



More information about the Squeak-dev mailing list