Deriving (& dying) from Semaphore
Lex Spoon
lex at cc.gatech.edu
Tue Apr 25 17:14:32 UTC 2000
jchludzinski at grci.com wrote:
>
> I attempted to derive a class from Semaphore but died sending the message #forMutualExclusion (to the derived class). The error occurs when the derived method #signal sends "self primitiveFailed". Why?
>
The primitive for Semaphore>>signal in Squeak looks like this:
primitiveSignal
| sema |
sema _ self stackTop. "rcvr"
self assertClassOf: sema is: (self splObj: ClassSemaphore).
successFlag ifTrue: [ self synchronousSignal: sema ].
Note the second-to-last line which explicitly checks the class of the
receiver--the receiver is expected to be *exactly* class Semaphore, and
not a subclass.
I guess it would be nice to be able to subclass Semaphore. Perhaps the
VM should check whether the receiver is a subclass of Semaphore, and
allow that as well. It doesn't seem like *that* big a deal that such a
low level class can't be subclassed, but then again, it would make for
awesome bragging rights for Squeak. :)
-Lex
More information about the Squeak-dev
mailing list
|