[BUG] recursive block calls

Stephan Rudlof sr at evolgo.de
Wed Jul 19 20:01:49 UTC 2000


"Change Set:		PseudoBlockClosure
Date:			19 July 2000
Author:			Stephan Rudlof

Adhoc approach to simulate BlockClosures; from the class comment of
PseudoBlockClosure:

PseudoBlockClosure should work as BlockClosure for blocks whithout
references to vars outside the block.
See class >>test* for examples.


DoIts

doesn´t work!

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

Transcript cr; show: (factorial value: 4 value: 1) printString


works!

| factorial |
factorial :=
    PseudoBlockClosure on: [:n :z |
    n == 0
        ifTrue: [z]
        ifFalse: [factorial value: (n-1) value: (z*n)]].

Transcript cr; show: (factorial value: 4 value: 1) printString
"

Michael Lucas-Smith wrote:
> 
> Hmm. I've just run in to the most puzzling problem. This seems to be
> something written in to the VM. If I define a block of code, I can't get
> that block to call itself! - This cannot be right.. as it's something
> I've done with IBM ST before.
> 
> | factorial |
> factorial :=
>     [:n :z |
>     n == 0
>         ifTrue: [z]
>         ifFalse: [factorial value: (n-1) value: (z*n)]].
> 
> Transcript show: (factorial value: 4 value: 1) printString
> 
> It works if I actually make 'factorial' a method. Please dont bother
> criticising the fact that I'm re-writing code that already exists in the
> system. I'm doing this for person reasons, and I was trying to see if my
> bit of code would run faster under Squeak than under IBM ST.
> But.. yeah... why does it say:
> 
> 'Attempt to evaluate a block that is already being evaluated.' ?
> 
> Michael.

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PseudoBlockClosure.1.cs
Type: application/octet-stream
Size: 4309 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20000719/08feb381/PseudoBlockClosure.1.obj


More information about the Squeak-dev mailing list