Hi,
I was playing with true:
Supposes you inspect 'True basicNew'. It return a new instance of True but the following don't work:
True basicNew ifTrue:[true]
Strange?
I have try to debug it and it fail on basicNew ??
I have inspect a CompiledMethod with this code and I saw:
21 <41> pushLit: True 22 <D0> send: basicNew 23 <98> jumpFalse: 25 24 <79> return: true 25 <78> returnSelf
That seems to be correct but at run time it don't do this ?? How come?
Thx
Math
You mustn't create new instances of true/false/nil because the sole instance of these class is known by the VM which use them for ifTrue:/ifFalse test (with a test like ==). Smalltalk is an open system, but there you reached the limits due to VM optimizations.
For curiosity, i tried the expression with other dialects, VW and gst both fail with mustBeBoolean error (True basicNew is neither recognized as a Boolean), and stx does forbid use of basicNew on True. The latter protection is maybe the right behavior.
Nicolas
Le Jeudi 03 Août 2006 20:54, Mathieu a écrit :
Hi,
I was playing with true:
Supposes you inspect 'True basicNew'. It return a new instance of True but the following don't work:
True basicNew ifTrue:[true]
Strange?
I have try to debug it and it fail on basicNew ??
I have inspect a CompiledMethod with this code and I saw:
21 <41> pushLit: True 22 <D0> send: basicNew 23 <98> jumpFalse: 25 24 <79> return: true 25 <78> returnSelf
That seems to be correct but at run time it don't do this ?? How come?
Thx
Math _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
beginners@lists.squeakfoundation.org