[Pharo-project] numLiterals > 0 is that possible?

Mariano Martinez Peck marianopeck at gmail.com
Sat Aug 18 12:57:36 CEST 2012


On Sat, Aug 18, 2012 at 12:33 PM, Camillo Bruni <camillobruni at gmail.com>wrote:

>
> On 2012-08-17, at 22:50, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
> > On Fri, Aug 17, 2012 at 1:42 PM, Mariano Martinez Peck <
> > marianopeck at 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.
>
> so it will never happen in Pharo right?
>
> > 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).
>
> again, this is not pharo mentality...
>
>
Yes, that was my point. Our system is full of  "xx > yyy ifZZ:" ,
"isEmptyOrNil ifZZ:", "ifNil: " blah blah blah. I am sure lost of them were
workaround introduced to solve a problem in some point in time in the last
20 years. And not only at a point in time, but also together with an
specific image version, set of libraries, vm, etc. I am also sure lots of
them may not be necessary anymore after so many cleanings and library
replacement. Hence, my question.

Finally, if Pharo would have followed the IIABDFI (If it ain't broke don't
fix it) then we would still have ReferenceStream, ImageSegment, HTTPSocket,
Preferences, FileDirectory, SystemChangeNotifier,  and many others around
(of course, someone could consider them as broken).


-- 
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20120818/e7b5078c/attachment.html>


More information about the Pharo-project mailing list