About true

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

About true

Mathieu SUEN
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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: About true

Nicolas Cellier-3
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
> [hidden email]
> http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners