Questions regarding thisContext

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

Questions regarding thisContext

Holger Freyther
Hi Paolo,

one quick question (can't reproduce the other thing)

thisContext ip: (thisContext ip). Should it work? For me it complains that the
result is no SmallInteger but if I print it it tells it is a SmallInteger? Any
idea how this could happen? My test case is actually assigning this to a local
variable.

regards
        holger

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Questions regarding thisContext

Paolo Bonzini-2
On 04/03/2011 04:11 PM, Holger Hans Peter Freyther wrote:
> Hi Paolo,
>
> one quick question (can't reproduce the other thing)
>
> thisContext ip: (thisContext ip). Should it work? For me it complains that the
> result is no SmallInteger but if I print it it tells it is a SmallInteger? Any
> idea how this could happen?

That's correct:

     0: source line 1
        push Global Variable[0] = ContextPart
     2: send special message #thisContext
     4: push Global Variable[0] = ContextPart
     6: send special message #thisContext
     8: send selector 1, 0 args = #ip
    10: send selector 2, 1 args = #ip:
    12: return stack top

The stack after bytecode 8 is

        thisContext, 10

The stack after bytecode 10 is

        thisContext

So the stack underflows when sending #ip: for the second time.  All bets
are off with respect to what happens afterwards.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk