class Apex(nil) { } class(#limited) Error(Apex) { pooldic Code { ENOERR := #\E0, EGENERIC := #\E1, ENOIMPL := #\E2, ESYSERR := #\E3, EINTERN := #\E4, ESYSMEM := #\E5, EOOMEM := #\E6, EINVAL := #\E7, ENOENT := #\E8, EPERM := #\E12, ERANGE := #\E20, ELIMIT := #\E9999 // add more items... } } /* pooldic Error.Code { ENOERR := #\E0, EGENERIC := #\E1, ENOIMPL := #\E2, ESYSERR := #\E3, EINTERN := #\E4, ESYSMEM := #\E5, EOOMEM := #\E6, EINVAL := #\E7, ENOENT := #\E8, EPERM := #\E12, ERANGE := #\E20, ELIMIT := #\E9999 // add more items... } */ /*pooldic Error.Code2 { >> CAN I SUPPORT this kind of redefnition? as of now, it's not accepted because >> Error.Code2.EGENERIC is not a literal. Should i treate pooldic members as a constant >> and treat it as if it's a literal like? then even if the defined value changes, >> the definition here won't see the change... what is the best way to tackle this issue? EGENERIC := Error.Code2.EGENERIC }*/ extend Apex { // ------------------------------------------------------- // ------------------------------------------------------- method(#dual) dump { } // ------------------------------------------------------- // ------------------------------------------------------- method(#dual) yourself { ^self } // ------------------------------------------------------- // INSTANTIATION & INITIALIZATION // ------------------------------------------------------- method(#class,#primitive,#lenient) _basicNew. method(#class,#primitive,#lenient) _basicNew: size. method(#class,#primitive) basicNew. method(#class,#primitive) basicNew: size. /* the following definition is almost equivalent to the simpler definition * method(#class,#primitive) basicNew: size. * found above. * in the following defintion, the primitiveFailed method is executed * from the basicNew: context. but in the simpler definition, it is executed * in the context of the caller of the basicNew:. the context of the basicNew: * method is not even created method(#class) basicNew: size { self primitiveFailed(thisContext method) }*/ method(#class) new { | x | x := self basicNew. x initialize. // TODO: assess if it's good to call 'initialize' from new ^x. } method(#class) new: anInteger { | x | x := self basicNew: anInteger. x initialize. // TODO: assess if it's good to call 'initialize' from new. ^x. } method initialize { /* a subclass may override this method */ ^self. } // ------------------------------------------------------- // ------------------------------------------------------- method(#dual,#primitive,#lenient) _shallowCopy. method(#dual,#primitive) shallowCopy. method(#dual,#primitive,#lenient) _copy. // alias to _shallowCopy method(#dual,#primitive) copy. // alias to shallowCopy // ------------------------------------------------------- // ------------------------------------------------------- method(#dual,#primitive,#lenient) _basicSize. method(#dual,#primitive) basicSize. method(#dual,#primitive,#lenient) _basicFirstIndex. method(#dual,#primitive) basicFirstIndex. method(#dual,#primitive,#lenient) _basicLastIndex. method(#dual,#primitive) basicLastIndex. method(#dual,#primitive) basicAt: index. // set the slot at the given index to the new value and return the new value. method(#dual,#primitive) basicAt: index put: newvalue. // set the slot at the give index to the new value if the existing value is identical to the old value. // return true if the existing value is identical to the old value and false otherwise. method(#dual,#primitive) basicAt: index test: oldvalue put: newvalue. method(#dual,#primitive) basicFillFrom: sindex with: value count: count. method(#dual,#primitive) basicShiftFrom: sindex to: dindex count: count. /* ------------------------------------------------------------------ * FINALIZATION SUPPORT * ------------------------------------------------------------------ */ method(#dual,#primitive) addToBeFinalized. method(#dual,#primitive) removeToBeFinalized. /* ------------------------------------------------------------------ * HASHING * ------------------------------------------------------------------ */ method(#dual,#primitive) hash. /* method(#dual) hash { self subclassResponsibility: #hash }*/ /* ------------------------------------------------------------------ * IDENTITY TEST * ------------------------------------------------------------------ */ // check if the receiver is identical to anObject. // this doesn't compare the contents method(#dual, #primitive) == anObject. method(#dual) ~~ anObject { ^(self == anObject) not. } /* ------------------------------------------------------------------ * EQUALITY TEST * ------------------------------------------------------------------ */ method(#dual) = anObject {