[squeak-dev] The Inbox: MorphicExtras-dtl.214.mcz

H. Hirzel hannes.hirzel at gmail.com
Tue Nov 14 04:25:45 UTC 2017


On 11/14/17, David T. Lewis <lewis at mail.msen.com> wrote:
> I had wondered the same thing, but I have not raised the question. I expect
> that the right thing to do would be to remove all references to the global
> in the code, but to retain the actual global. After all, its value is only
> set in a couple of methods, so that is easy enough to maintain.

Yes.

> Aside from the point you are raising, I would also be concerned that
> there are externally maintained packages that may expect these well-known
> global variables to be present. Etoys would be an obvious example, but
> there probably are others.

Indeed. Unnecessary references to the globals World and ActiveWorld
should be reduced but they should be maintained.


It still would be good to now what the difference between World and
ActiveWorld is.....

Open question here:

ActiveWorld
http://wiki.squeak.org/squeak/1104


> Yes I know tha Etoys is in the trunk right now,
> but hopefully it will be a fully reloadable package that can be maintained
> independently, and I would expect that Scratch and various other externally
> maintained things might have expectations regarding well-known globals.
>
> From my personal perspective, success means that if I were to remove the
> global variable World, the system would still work. Sort of like having
> MVC be reloadable: I want to be able to unload it, load it back into the
> system, and have MVC still be working. Once that is done, I am happy.
> That does not mean I would actually remove MVC from any image that I
> actually use, why would anyone ever want to do that?!?
>
> Dave
>
>
> On Mon, Nov 13, 2017 at 09:51:41PM -0600, Chris Muller wrote:
>> Thanks for the clarification, however I'm still not clear if you're
>> saying you intend to remove "World" as a Smalltalk global, or only
>> references to it in the code.  I hope only the latter.  It starts to
>> become cumbersomely wordy is in everyday debugging having to type
>> "Project current world submorphs detect: [ ... ]" in inspectors to
>> find my morph instead of only "World submorphs detect: [ ...]".
>>
>>  - Chris
>>
>> On Mon, Nov 13, 2017 at 9:23 PM, David T. Lewis <lewis at mail.msen.com>
>> wrote:
>> > Hi Chris,
>> >
>> > I did not intend to move all those packages to trunk right after you
>> > posted this, I had thought that there were no further comments and did
>> > not see your message while I was doing the moves. The neglect was not
>> > intentional.
>> >
>> > On Mon, Nov 13, 2017 at 07:29:29PM -0600, Chris Muller wrote:
>> >> Why?  This is a sad move for users who want to program the
>> >> environment, and it does little or nothing to make it any safer.  Is
>> >> it because "globals are bad?"  I hope not.
>> >>
>> >> Should I assume that you mean to make Display, Processor, and other
>> >> globals disappear too?  If so, what about classes, as Smalltalkers we
>> >> like to tell people they're "objects" too, so why make this sort of
>> >> access "exceptional" to classes only?
>> >
>> > No, it is quite specific to the problem of project navigation, as well
>> > as better support of multiple (possibly concurrent?) project types. The
>> > idea is to avoid using globals to cache information that is, or should
>> > be,
>> > local to a Project. I have spent some time debugging these things in the
>> > past, and is quite clear to me that unnecessary use of globals for
>> > things
>> > that are not really global is a Really Bad Idea, especially when you are
>> > dealing with things that drop you into an emergency evaluator when they
>> > do not work.
>> >
>> > To some extent I am also looking forward to Morphic3 which is being
>> > developed
>> > in Cuis. It should in principle be able to host this in Squeak, and I
>> > did
>> > some work a number of years ago
>> > (http://www.squeaksource.com/SimpleMorphicSqueak)
>> > on an early proof of concept. That proof of concept was "successful" in
>> > the sense that it worked, but it was also quite clear that some
>> > housekeeping
>> > was was going to be needed in Squeak (specifically around Projects) in
>> > order
>> > for things like this to be sustainable beyond just the proof of concept
>> > level. So I am not trying to take anything away from Squeak, just trying
>> > to scratch a long standing itch and maybe tidy up the system a little
>> > bit
>> > in the process.
>> >
>> > I hope you understand that "world global elimination" was just a small
>> > joke, I do not really intend to make any important things disappear ;-)
>> >
>> > Dave
>> >
>> >>
>> >> On Sat, Nov 11, 2017 at 3:05 PM,  <commits at source.squeak.org> wrote:
>> >> > David T. Lewis uploaded a new version of MorphicExtras to project The
>> >> > Inbox:
>> >> > http://source.squeak.org/inbox/MorphicExtras-dtl.214.mcz
>> >> >
>> >> > ==================== Summary ====================
>> >> >
>> >> > Name: MorphicExtras-dtl.214
>> >> > Author: dtl
>> >> > Time: 11 November 2017, 4:05:52.716283 pm
>> >> > UUID: 297c9f00-e80a-4a90-a1aa-5f3a26a835d0
>> >> > Ancestors: MorphicExtras-pre.213
>> >> >
>> >> > World global elimination. Once the current project has been entered,
>> >> > Project current world == World. Begin eliminating references to the
>> >> > global variable World in cases where it is not required.
>> >> >
>> >> > =============== Diff against MorphicExtras-pre.213 ===============
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: BookMorph>>loadImagesIntoBook (in category 'menu')
>> >> > -----
>> >> >   loadImagesIntoBook
>> >> >         "PowerPoint stores GIF presentations as individual slides
>> >> > named Slide1, Slide2, etc.
>> >> >         Load these into the book.  mjg 9/99"
>> >> >
>> >> >         | directory filenumber form newpage |
>> >> >         directory := ((StandardFileMenu oldFileFrom: FileDirectory
>> >> > default)
>> >> >                                 ifNil: [^nil]) directory.
>> >> >         directory isNil ifTrue: [^nil].
>> >> >
>> >> >         "Start loading 'em up!!"
>> >> >         filenumber := 1.
>> >> >         [directory fileExists: 'Slide' , filenumber asString]
>> >> > whileTrue:
>> >> >                         [Transcript
>> >> >                                 show: 'Slide' , filenumber asString;
>> >> >                                 cr.
>> >> >                         Smalltalk bytesLeft < 1000000
>> >> >                                 ifTrue:
>> >> >                                         ["Make some room"
>> >> >
>> >> >                                         (self valueOfProperty: #url)
>> >> > isNil
>> >> >                                                 ifTrue: [self
>> >> > savePagesOnURL]
>> >> >                                                 ifFalse: [self
>> >> > saveAsNumberedURLs]].
>> >> >                         form := Form
>> >> >                                                 fromFileNamed:
>> >> > (directory fullNameFor: 'Slide' , filenumber asString).
>> >> >                         newpage := PasteUpMorph new extent: form
>> >> > extent.
>> >> > +                       newpage addMorph: (Project current world
>> >> > drawingClass withForm: form).
>> >> > -                       newpage addMorph: (World drawingClass
>> >> > withForm: form).
>> >> >                         self pages addLast: newpage.
>> >> >                         filenumber := filenumber + 1].
>> >> >
>> >> >         "After adding all, delete the first page."
>> >> >         self goToPage: 1.
>> >> >         self deletePageBasic.
>> >> >
>> >> >         "Save the book"
>> >> >         (self valueOfProperty: #url) isNil
>> >> >                 ifTrue: [self savePagesOnURL]
>> >> >                 ifFalse: [self saveAsNumberedURLs]!
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: GraphicalDictionaryMenu>>handMeOne (in category 'menu
>> >> > commands') -----
>> >> >   handMeOne
>> >> > +       self currentHand attachMorph: (Project current world
>> >> > drawingClass new form: (formChoices at: currentIndex))!
>> >> > -       self currentHand attachMorph: (World drawingClass new form:
>> >> > (formChoices at: currentIndex))!
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: GraphicalDictionaryMenu>>repaintEntry (in category
>> >> > 'menu commands') -----
>> >> >   repaintEntry
>> >> >         "Let the user enter into painting mode to repaint the item
>> >> > and save it back."
>> >> >
>> >> >         | aWorld bnds sketchEditor aPaintBox formToEdit |
>> >> >
>> >> >         (aWorld := self world) assureNotPaintingElse: [^ self].
>> >> >
>> >> >         aWorld prepareToPaint.
>> >> >         aWorld displayWorld.
>> >> >         formToEdit := formChoices at: currentIndex.
>> >> >         bnds := (submorphs second boundsInWorld origin extent:
>> >> > formToEdit extent) intersect: aWorld bounds.
>> >> >         bnds := (aWorld paintingBoundsAround: bnds center) merge:
>> >> > bnds.
>> >> >         sketchEditor := SketchEditorMorph new.
>> >> >         aWorld addMorphFront: sketchEditor.
>> >> > +       sketchEditor initializeFor: ((aWorld drawingClass withForm:
>> >> > formToEdit) position: submorphs second positionInWorld)  inBounds:
>> >> > bnds pasteUpMorph: aWorld paintBoxPosition: bnds topRight.
>> >> > -       sketchEditor initializeFor: ((World drawingClass withForm:
>> >> > formToEdit) position: submorphs second positionInWorld)  inBounds:
>> >> > bnds pasteUpMorph: aWorld paintBoxPosition: bnds topRight.
>> >> >         sketchEditor
>> >> >                 afterNewPicDo: [:aForm :aRect |
>> >> >                         formChoices at: currentIndex put: aForm.
>> >> >                         baseDictionary at: (entryNames at:
>> >> > currentIndex) put: aForm.
>> >> >                         self updateThumbnail.
>> >> >                         (aPaintBox := aWorld paintBoxOrNil) ifNotNil:
>> >> > [aPaintBox delete]]
>> >> >                 ifNoBits:
>> >> >                         [(aPaintBox := aWorld paintBoxOrNil)
>> >> > ifNotNil: [aPaintBox delete]].
>> >> >
>> >> >   !
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: ProjectSorterMorph>>addControls (in category
>> >> > 'initialization') -----
>> >> >   addControls
>> >> >         "Add the control bar at the top of the tool."
>> >> >
>> >> >         | b r partsBinButton newButton aWrapper |
>> >> > +       newButton := ImageMorph new image: (Project current
>> >> > makeThumbnail scaledToSize: 48 at 36).
>> >> > -       newButton := ImageMorph new image: (World project
>> >> > makeThumbnail scaledToSize: 48 at 36).
>> >> >         newButton on: #mouseDown send: #insertNewProject: to: self.
>> >> >         newButton setBalloonText: 'Make a new Project' translated.
>> >> >         (partsBinButton := UpdatingThreePhaseButtonMorph checkBox)
>> >> >                 target: self;
>> >> >                 actionSelector: #togglePartsBinStatus;
>> >> >                 arguments: #();
>> >> >                 getSelector: #getPartsBinStatus.
>> >> >         (r := AlignmentMorph newRow)
>> >> >                 color: Color transparent;
>> >> >                 borderWidth: 0;
>> >> >                 layoutInset: 0;
>> >> >                 cellInset: 10 at 0;
>> >> >                 wrapCentering: #center;
>> >> >                 cellPositioning: #leftCenter;
>> >> >                 hResizing: #shrinkWrap;
>> >> >                 vResizing: #shrinkWrap;
>> >> >                 extent: 5 at 5.
>> >> >         b := SimpleButtonMorph new target: self; color: self
>> >> > defaultColor darker;
>> >> >                         borderColor: Color black.
>> >> >         r addMorphBack: (self wrapperFor: (b label: 'Okay' translated
>> >> > font: ScriptingSystem fontForEToyButtons; actionSelector:
>> >> > #acceptSort)).
>> >> >         b := SimpleButtonMorph new target: self; color: self
>> >> > defaultColor darker;
>> >> >                         borderColor: Color black.
>> >> >         r addMorphBack: (self wrapperFor: (b label: 'Cancel'
>> >> > translated font: ScriptingSystem fontForEToyButtons; actionSelector:
>> >> > #delete));
>> >> >                 addTransparentSpacerOfSize: 8 @ 0;
>> >> >                 addMorphBack: (self wrapperFor: (newButton));
>> >> >                 addTransparentSpacerOfSize: 8 @ 0.
>> >> >
>> >> >         aWrapper := AlignmentMorph newRow beTransparent.
>> >> >         aWrapper cellInset: 0; layoutInset: 0; borderWidth: 0.
>> >> >         aWrapper
>> >> >                 addMorphBack: (self wrapperFor: partsBinButton);
>> >> >                 addMorphBack: (self wrapperFor: (StringMorph
>> >> > contents: 'Parts bin' translated font: ScriptingSystem
>> >> > fontForEToyButtons) lock).
>> >> >         r addMorphBack: aWrapper.
>> >> >
>> >> >         self addMorphFront: r.
>> >> >   !
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: SpeakerMorph>>addGraphic (in category
>> >> > 'initialization') -----
>> >> >   addGraphic
>> >> >
>> >> >         | graphic |
>> >> > +       graphic := Project current world drawingClass withForm: self
>> >> > speakerGraphic.
>> >> > -       graphic := World drawingClass withForm: self speakerGraphic.
>> >> >         graphic position: bounds center - (graphic extent // 2).
>> >> >         self addMorph: graphic.
>> >> >   !
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: SqueakPage>>prePurge (in category 'saving') -----
>> >> >   prePurge
>> >> >         "Return self if ready to be purged, or nil if not"
>> >> >
>> >> >         self isContentsInMemory ifFalse: [^ nil].
>> >> >         contentsMorph ifNil: [^ nil].  "out already"
>> >> >         url ifNil: [^ nil].     "just to be safe"
>> >> > +       ^ (Project current world ~~ nil and: [contentsMorph world ==
>> >> > World])
>> >> > -       ^ (World ~~ nil and: [contentsMorph world == World])
>> >> >                 ifTrue: [nil "showing now"] ifFalse: [self]!
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: TabbedPalette class>>authoringPrototype (in category
>> >> > 'scripting') -----
>> >> >   authoringPrototype
>> >> >         | aTabbedPalette aBook aTab |
>> >> >         aTabbedPalette := self new markAsPartsDonor.
>> >> >         aTabbedPalette pageSize: 200 @ 300.
>> >> >         aTabbedPalette tabsMorph highlightColor: Color red
>> >> > regularColor: Color blue.
>> >> >         aTabbedPalette addMenuTab.
>> >> >
>> >> >         aBook := BookMorph new setNameTo: 'one'; pageSize:
>> >> > aTabbedPalette pageSize.
>> >> >         aBook color: Color blue muchLighter.
>> >> >         aBook removeEverything; insertPage; showPageControls.
>> >> > +       aBook currentPage addMorphBack: (Project current world
>> >> > drawingClass withForm: ScriptingSystem squeakyMouseForm).
>> >> > -       aBook currentPage addMorphBack: (World drawingClass withForm:
>> >> > ScriptingSystem squeakyMouseForm).
>> >> >         aTab := aTabbedPalette addTabForBook: aBook.
>> >> >
>> >> >         aBook := BookMorph new setNameTo: 'two'; pageSize:
>> >> > aTabbedPalette pageSize.
>> >> >         aBook color: Color red muchLighter.
>> >> >         aBook removeEverything; insertPage; showPageControls.
>> >> >         aBook currentPage addMorphBack: CurveMorph
>> >> > authoringPrototype.
>> >> >         aTabbedPalette addTabForBook: aBook.
>> >> >
>> >> >         aTabbedPalette selectTab: aTab.
>> >> >
>> >> >         aTabbedPalette beSticky.
>> >> >         aTabbedPalette tabsMorph hResizing: #spaceFill.
>> >> >         ^ aTabbedPalette!
>> >> >
>> >> > Item was changed:
>> >> >   ----- Method: TabbedPalette>>addMenuTab (in category 'palette
>> >> > menu') -----
>> >> >   addMenuTab
>> >> >         "Add the menu tab.  This is ancient code, not much in the
>> >> > spirit of anything current"
>> >> >
>> >> >         | aMenu aTab aGraphic sk |
>> >> >         aMenu := MenuMorph new defaultTarget: self.
>> >> >         aMenu stayUp: true.
>> >> >         "aMenu add:  'clear' translated action: #showNoPalette."
>> >> >         aMenu add:  'sort tabs' translated action: #sortTabs:.
>> >> >         aMenu add:  'choose new colors for tabs' translated action:
>> >> > #recolorTabs.
>> >> >         aMenu setProperty: #paletteMenu toValue: true.
>> >> >         "aMenu add:  'make me the Standard palette' translated
>> >> > action: #becomeStandardPalette."
>> >> >         aTab := self addTabForBook: aMenu  withBalloonText: 'a menu
>> >> > of palette-related controls' translated.
>> >> >         aTab highlightColor: tabsMorph highlightColor; regularColor:
>> >> > tabsMorph regularColor.
>> >> >         tabsMorph laySubpartsOutInOneRow; layoutChanged.
>> >> >
>> >> >         aGraphic := ScriptingSystem formAtKey: 'TinyMenu'.
>> >> >         aGraphic ifNotNil:
>> >> >                 [aTab removeAllMorphs.
>> >> > +               aTab addMorph: (sk := Project current world
>> >> > drawingClass withForm: aGraphic).
>> >> > -               aTab addMorph: (sk := World drawingClass withForm:
>> >> > aGraphic).
>> >> >                 sk position: aTab position.
>> >> >                 sk lock.
>> >> >                 aTab fitContents].
>> >> >         self layoutChanged!
>> >> >
>> >> >
>> >>
>>
>
>


More information about the Squeak-dev mailing list