On Fri, Aug 17, 2012 at 1:42 PM, Mariano Martinez Peck <
marianop...@gmail.com> wrote:

> Hi guys. Right now we have
>
> methodClass
> "answer the class that I am installed in"
> ^self numLiterals > 0
>  ifTrue: [ (self literalAt: self numLiterals) value ]
> ifFalse: [ nil ]
>
> But of course my image has no method with 0 literals:
>
> (CompiledMethod allInstances select: [:each | each numLiterals = 0 ]) size
> -> 0
>
> So...can this really happen? or I can just remove the if ?
>

Yes it could happen.  For example, i the Newspeak implementation above
Squeak these is a collection of inst-var accessors that are shared through
all Newspeak classes in the system.  These have a nil methodClass.  If one
wanted to save space they could have no methodClass instead of nil in the
methodClass slot.  (Note that the above works for these since nil value =
value).  So IMO its a harmless piece of defensice programming.  IIABDFI (If
it ain't broke don't fix it).



>
> thanks
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>


-- 
best,
Eliot

Reply via email to