BlockContext and returns...

Benoit St-Jean bstjean at yahoo.com
Tue Jan 22 01:57:27 UTC 2002


Is there any reason to return from inside a block
rather than returning the value of the expression when
both are the same.  Besides the fact that it sometimes
makes the code more clear, I don't get it?

For instance why would you write:

anObject isFoo
   ifTrue: [^#foo]
   ifFalse: [^#bar]


instead of:

^anObject isFoo
   ifTrue: [#foo]
   ifFalse: [#bar]

There are a few occurences of this within Squeak.  For
instance, Object>>isKindOf: is like that.  Is there
anything special about the VM or BlockContext that
would make the first solution "faster or better".  I
always thought that clean blocks was the way to go and
that you should always try to avoid returning from
inside a block when possible, so what's the deal here?
 Just curious.

BTW, if you look at senders of ifTrue:ifFalse: (or
vice-versa) you only get a few methods...  Is it
broken or that is the normal "behavior" since that
"message" is inlined and not reaaly a message send?

Thanks.






=====
-------------------------
Benoit St-Jean
bstjean at yahoo.com
Yahoo! Messenger: bstjean
http://cactus.swiki.net
-------------------------

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/



More information about the Squeak-dev mailing list