Unexecuted code

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

Unexecuted code

Zulq Alam
Perhaps it's my lack of experience with Smalltalk but I'm struggling to
understand what happens to code which is not executed after an answer.

go
    parameter isNil:
        [self inform: 'You must specify a parameter.'.
       self answer].
    someObject someActionWith: parameter.
    self answer.

Let's assume that "parameter" is set by some form input which in this
case is nil. I would expect the last two statements to execute when
"self answer" returns which, as I understand, never will.

So, what happens to the last two statements? They must have been on the
stack (or whatever Squeak/Smalltalk uses!) and I would assume that "self
answer" pushes on to the stack. So doesn't the stack grow indefinitely?

Thanks,
Zulq.
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Unexecuted code

Avi  Bryant

On Mar 18, 2006, at 8:42 AM, Zulq Alam wrote:

> Perhaps it's my lack of experience with Smalltalk but I'm  
> struggling to understand what happens to code which is not executed  
> after an answer.
>
> go
>    parameter isNil:
>        [self inform: 'You must specify a parameter.'.
>       self answer].
>    someObject someActionWith: parameter.
>    self answer.
>
> Let's assume that "parameter" is set by some form input which in  
> this case is nil. I would expect the last two statements to execute  
> when "self answer" returns which, as I understand, never will.
>
> So, what happens to the last two statements? They must have been on  
> the stack (or whatever Squeak/Smalltalk uses!) and I would assume  
> that "self answer" pushes on to the stack. So doesn't the stack  
> grow indefinitely?

No, #answer blows away the current stack - think of it like a longjmp.

Cheers,
Avi
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Unexecuted code

Zulq Alam
Thanks.

Avi Bryant wrote:

>
> On Mar 18, 2006, at 8:42 AM, Zulq Alam wrote:
>
>> Perhaps it's my lack of experience with Smalltalk but I'm struggling
>> to understand what happens to code which is not executed after an
>> answer.
>>
>> go
>>    parameter isNil:
>>        [self inform: 'You must specify a parameter.'.
>>       self answer].
>>    someObject someActionWith: parameter.
>>    self answer.
>>
>> Let's assume that "parameter" is set by some form input which in this
>> case is nil. I would expect the last two statements to execute when
>> "self answer" returns which, as I understand, never will.
>>
>> So, what happens to the last two statements? They must have been on
>> the stack (or whatever Squeak/Smalltalk uses!) and I would assume
>> that "self answer" pushes on to the stack. So doesn't the stack grow
>> indefinitely?
>
> No, #answer blows away the current stack - think of it like a longjmp.
>
> Cheers,
> Avi
> _______________________________________________
> Seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside