[squeak-dev] Class with nil environment?!

Bob Arning arning315 at comcast.net
Wed Jul 10 22:50:09 UTC 2013


On 7/10/13 5:59 PM, Frank Shearar wrote:
> Well, with my nil-hating hat on, I'd say that Class >> #environment is
> also busted. There's no value in having environment = nil.
It allows subclasses to track the superclass environment. You can change 
the environment for a class and all subclasses that have not explicitly 
declared an environment will share it. Subclasses that have had an 
explicit environment set will keep that that even when the superclass 
changes.
> You're not
> saving any space, for instance. What you _do_ have is a piece of
> uninitialised state, waiting for someone to reference the instvar
> directly (as Class >> #declare: does) and fail with an MNU on nil.
>
> I'm waiting to hear what Colin has to say, but I'd say that Class >>
> #declare: has every reason to assume that an instvar's initialised,
> and that #environment should simply say "^ environment".
The counter-argument, of course, is to use the accessors and not tinker 
directly with the instvars unless you are sure you know what you are doing.
> And that we
> need _something_ to crawl the Class instances and fix the instvar, of
> course. So _maybe_ saying ^ environment ifNil: [environment :=
> Smalltalk globals] might be OK in #environment.
>
> frank
>
> On 10 July 2013 22:49, Bob Arning <arning315 at comcast.net> wrote:
>> Not sure why you think it's busted. It's been that way for a very long time
>> and Class>>environment seems to take care of things:
>>
>> environment
>>
>>      environment == nil ifTrue: [^ super environment].
>>      ^ environment
>>
>> Cheers,
>> Bob
>>
>> On 7/10/13 5:38 PM, Frank Shearar wrote:
>>
>> On 10 July 2013 22:19, Frank Shearar <frank.shearar at gmail.com> wrote:
>>
>> On 10 July 2013 20:44, David T. Lewis <lewis at mail.msen.com> wrote:
>>
>> On Wed, Jul 10, 2013 at 07:21:56PM +0100, Frank Shearar wrote:
>>
>> On 10 July 2013 19:02, Colin Putney <colin at wiresong.com> wrote:
>>
>>
>> On Wed, Jul 10, 2013 at 6:52 AM, Frank Shearar <frank.shearar at gmail.com>
>> wrote:
>>
>> Er, so should we ever have classes with a nil environment? Is my
>> proposed change a stinky hack, or the right thing to do to lazily fix
>> the issue?
>>
>> We should never have classes with a nil environment.
>>
>> OK, that's what I thought. But I have such an image. In fact, I
>> daresay that every alpha image produced in the 4.5 line has for months
>> and months had such classes. Making #declare: use the #environment
>> method instead of directly accessing the instvar "solves" the problem
>> - Morphic-fbs.633 will load - but I have no idea if that's a good
>> solution, or a bad, bad bandaid.
>>
>> I have run into the nil environment problem in the course of updating
>> images from trunk, so I suspect there is or was some kind of problem
>> at some point. I worked around it manually in the update whenever a
>> debugger popped up. The "fix" was to look at the class in the debugger,
>> and do "environment := Array environment" (I used Array, but it could
>> be any class that does have its environment set properly).
>>
>> That seemed to work but I'm sure there must be a better way to do it.
>> Is there something we should put into the trunk update stream so that
>> other people don't get stuck on the problem during updates?
>>
>> Dave
>>
>> I sort've expected to see an explicit assigning of environments
>> somewhere. But Environment class >> #install doesn't do this. It
>> inserts itself in Smalltalk globals' place, which is great if a (class
>> instVarNamed: 'environment') == Smalltalk globals. But if a class'
>> environment was already nil, installing Environments would not have
>> touched the instvar, leaving busted state. (As in, leaving busted
>> state in the same, busted, state.)
>>
>> And lo! In a Squeak 4.4 image:
>>
>> (Class allSubclasses collect: #theNonMetaClass) select: [:cls | (cls
>> instVarNamed: 'environment') isNil]
>> "=> " an OrderedCollection(ProtoObject ObjectViewer ObjectOut
>> BalloonState SoundCodec UndefinedObject Boolean SimpleMIDIPort
>> FillStyle Password SharedQueue MidiPrimTester MailAddressParser
>> WindowingTransformation FormButtonCache BalloonEdgeData View
>> AbstractScoreEvent LimitingLineStreamWrapper Message
>> EllipseMidpointTracer DamageRecorder ImageReadWriter TextContainer
>> MIDIScore ClassCategoryReader BalloonSolidFillSimulation
>> MorphExtension MIDISynth MIMEDocument FWT TextAttribute MIDIFileReader
>> Stream Link BalloonBuffer SerialPort MimeConverter CornerRounder
>> CompressedBoundaryShape MailAddressToken BalloonLineSimulation
>> DiskProxy LineSegment Point DisplayObject CompressedSoundData
>> InstructionStream BalloonFillData GraphicSymbolInstance PluggableTest
>> KeyboardBuffer ParseStack Morph MIDISynthChannel DisplayTransform
>> ObjectScanner Envelope SampledInstrument MIDIInputParser ClassBuilder
>> FFT ExceptionSet ObjectViewer WaveletCodec MuLawCodec GSMCodec
>> ADPCMCodec True False OrientedFillStyle SolidFillStyle Pen WarpBlt
>> FormView DisplayTextView StringHolderView ListView PluggableButtonView
>> Number LookupKey NoteEvent ControlChangeEvent PitchBendEvent
>> ProgramChangeEvent AmbientEvent TempoEvent DualChangeSorter
>> TranslucentColor PCXReadWriter XBMReadWriter Quadrangle Bag
>> SequenceableCollection TextAction TextKern TextEmphasis TextIndent
>> TextColor TextFontChange PositionableStream DummyStream
>> QuotedPrintableMimeConverter RepeatingSound ScorePlayer
>> SequentialSound RestSound ReverbSound FMSound PluckedSound MixedSound
>> UnixFileDirectory DosFileDirectory Bezier2Segment Bezier3Segment
>> DisplayText DisplayMedium Path InfiniteForm GenericUrl
>> PianoRollNoteMorph ImageMorph MenuLineMorph StringMorph BorderedMorph
>> MovieMorph MatrixTransform2x3 CompositeTransform MorphicTransform
>> VolumeEnvelope RandomEnvelope PitchEnvelope SoundInputStream
>> AssignmentNode DecompilerConstructor CascadeNode BraceNode Error
>> IllegalResumeAttempt Notification FormMenuController ModalController
>> NoController BitmapFillStyle FormHolderView FormInspectView
>> FillInTheBlankView PluggableTextView PluggableListView FormEditorView
>> ColorSystemView Fraction Association SyntaxError SelectorBrowser
>> ArrayedCollection LinkedList OrderedCollection Interval TextDoIt
>> TextLink TextURL TextFontReference ReadStream WriteStream
>> RFC2047MimeConverter FMClarinetSound FMBassoonSound UnloadedSound Form
>> Spline CurveFitter Line LinearFit Arc BlockContext MailtoUrl
>> BrowserUrl HttpUrl FtpUrl ThreePhaseButtonMorph Sonogram
>> PopUpChoiceMorph MorphicModel RectangleMorph Canvas SelectorNode
>> VariableNode LiteralNode MessageAsTempNode ExceptionAboutToReturn
>> Warning PluggableListViewByItem SmallInteger LargePositiveInteger
>> WeakKeyAssociation OrderedCollectionInspector DictionaryInspector
>> InspectorBrowser ChangeList WordArray RunArray Array ShortIntegerArray
>> Bitmap FloatArray ShortRunArray ByteArray IntegerArray Semaphore
>> GraphicSymbol TextLineInterval IdentityDictionary WeakValueDictionary
>> PluggableDictionary TextSqkPageLink LimitedWriteStream ReadWriteStream
>> TextStream ListParagraph ColorForm Circle NameStringInHalo
>> ProjectController ListController LargeNegativeInteger
>> ChangeListForProjects FileContentsBrowser PackagePaneBrowser
>> ChangedMessageSet RecentMessageSet TimeProfileBrowser ShortPointArray
>> PointArray RWBinaryOrTextStream Transcripter CursorWithMask
>> PreDebugWindow SystemWindowWithButton ScorePlayerMorph
>> UpdatingSimpleButtonMorph TextMorphForEditView StringMorphEditor
>> ColorPatchCanvas PluggableListController PluggableListControllerOfMany
>> FillInTheBlankController PluggableTextController
>> ReadOnlyTextController)
>>
>> Note PianoRollNoteMorph's presence in the list! So. It's not
>> Environments' fault, because it just replaced Smalltalk globals. It's
>> just long old busted state. We thus need (a) an update step to fix the
>> busted state or (b) lazily correct it.
>>
>> frank
>>
>>
>>
>>
>>
>



More information about the Squeak-dev mailing list