About at: and basicAt difference

ducasse ducasse at iam.unibe.ch
Sun Jan 13 15:30:18 UTC 2002


Hi

I was thinking that Object>>at: and Object>>basicAt: would be exactly the
same. This seems true from a primitive point of view but not from the code
explaining the primitive.

Can somebody explain me why? It is a "bug" that would never occur since at
and basicAt are special primitives?
Which one is in sync with the primitive 60

Object>>at: index 
    "Primitive. Assumes receiver is indexable. Answer the value of an
    indexable element in the receiver. Fail if the argument index is not an
    Integer or is out of bounds. Essential. See Object documentation
    whatIsAPrimitive."

    <primitive: 60>
    index isInteger ifTrue:
        [self class isVariable
            ifTrue: [self errorSubscriptBounds: index]
            ifFalse: [self error: (self class name) , 's are not
indexable']].
    index isNumber
        ifTrue: [^self at: index asInteger]
        ifFalse: [self errorNonIntegerIndex]


Object>>basicAt: index
    "Primitive. Assumes receiver is indexable. Answer the value of an
    indexable element in the receiver. Fail if the argument index is not an
    Integer or is out of bounds. Essential. Do not override in a subclass.
See 
    Object documentation whatIsAPrimitive."

    <primitive: 60>
    index isInteger ifTrue: [self errorSubscriptBounds: index].
    index isNumber
        ifTrue: [^self basicAt: index asInteger]
        ifFalse: [self errorNonIntegerIndex]





More information about the Squeak-dev mailing list