[BUG]? methods seems to have no memory

Paul Dufresne dufrp at hotmail.com
Sun Jun 1 06:15:47 PDT 2003


According to Slate manual:
Blocks furthermore have the property that, although they are a piece of
code and the values they access may change between dening the closure
and invoking it, the code will ìrememberî what objects it depends
on, regardless of what context it may be passed to as a slot value. This
is critical for implementing good control structures in Slate, as is 
explained
later. Basically a block is an activation frame composed with
an environment that can be saved and invoked (perhaps multiple times)
long after it is created.

And now my little test:
Slate 1> lobby addSlot: #p.
<@Namespace:  traits lobby prototypes globals p>
Slate 2> lobby addSlot: #q.
<@Namespace:  traits lobby prototypes globals p q>
Slate 3> p: 'Paul'.
'Paul'
Slate 4> q: [ p ].
[]
Slate 5> q value.
'Paul'
Slate 6> p: 'Brian'.
'Brian'
Slate 7> q value.
'Brian'
Slate 8> 'Hey! I was expecting Paul here!'.
'Hey! I was expecting Paul here!'
Slate 9> q: [ | a | (a ifNil: [0] ifNotNil: [a + 1])].
[]
Slate 10> q.
[]
Slate 11> q value.
Backtrace
---------
Method value @ primitive
---------
Error: A method named 'ifNil:ifNotNil:' was not found for the arguments: 
(<@*PRI
MITIVE-NIL*: traits>
<@*PRIMITIVE-METHOD*: traits, lineNumber, fileName, selector, accessor, 
argumen
ts, lexicalParent, sourceCode, code, activation>
<@*PRIMITIVE-METHOD*: traits, lineNumber, fileName, selector, accessor, 
argumen
ts, lexicalParent, sourceCode, code, activation>)
Return to the Slate top level?  (y/n)
Please answer with y or n : y
Slate 12> p ifNil: [0] ifNotNil: [4].
Backtrace
---------
---------
Error: A method named 'ifNil:ifNotNil:' was not found for the arguments: 
(Brian
<@*PRIMITIVE-METHOD*: traits, lineNumber, fileName, selector, accessor, 
argumen
ts, lexicalParent, sourceCode, code, activation>
<@*PRIMITIVE-METHOD*: traits, lineNumber, fileName, selector, accessor, 
argumen
ts, lexicalParent, sourceCode, code, activation>)
Return to the Slate top level?  (y/n)
Please answer with y or n : p ifNil: [0] ifNotNil: [4].

Please answer with y or n : y
Slate 13> 'src/init.slate' fileIn.
Hi, there!
Nil
Slate 14> q value.
0
Slate 15> q value.
0
Slate 16> q value.
0

'hum, ok, all local variables are Nil and are not remembered.'.

'But I was expecting that since ifNil:ifNotNil: was not defined when I
defined the block in q, it should still does not know it!'.

_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis !  
http://messenger.fr.msn.ca/




More information about the Slate mailing list