Success flag and using return value of primitive function

Igor Stasenko siguctua at gmail.com
Fri Dec 7 12:11:23 UTC 2007


Currently, a VM expects nothing in return from primitive function
(actually functions have format sqInt (*)(void)  but result is not
used).

I'm wondering, why in VM , to indicate success, a successFlag global
variable used instead of just returning 0 or 1 to indicate if call was
successfull or not?

To what i see, if not using the successFlag , then speed can be
improved, because there will be less frequent reads and writes to
successFlag by simply reusing a return value from function which is
currently ignored.

The good point in using a successFlag is, that it can be set anywhere
in primitive and then do something else, and only then return from
function.
But a common scenarion is often look like:

something isWrong: [ ^ interpreterProxy primitiveFail ]

where primitiveFail internally sets successFlag to false.

So, can anyone provide arguments, why its done in such way?

-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list