The Inbox: MorphicExtras-dtl.214.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: MorphicExtras-dtl.214.mcz

commits-2
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@36).
- newButton := ImageMorph new image: (World project makeThumbnail scaledToSize: 48@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@0;
  wrapCentering: #center;
  cellPositioning: #leftCenter;
  hResizing: #shrinkWrap;
  vResizing: #shrinkWrap;
  extent: 5@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!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Chris Muller-3
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?

On Sat, Nov 11, 2017 at 3:05 PM,  <[hidden email]> 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@36).
> -       newButton := ImageMorph new image: (World project makeThumbnail scaledToSize: 48@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@0;
>                 wrapCentering: #center;
>                 cellPositioning: #leftCenter;
>                 hResizing: #shrinkWrap;
>                 vResizing: #shrinkWrap;
>                 extent: 5@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!
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

David T. Lewis
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,  <[hidden email]> 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@36).
> > -       newButton := ImageMorph new image: (World project makeThumbnail scaledToSize: 48@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@0;
> >                 wrapCentering: #center;
> >                 cellPositioning: #leftCenter;
> >                 hResizing: #shrinkWrap;
> >                 vResizing: #shrinkWrap;
> >                 extent: 5@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!
> >
> >
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Chris Muller-4
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 <[hidden email]> 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,  <[hidden email]> 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@36).
>> > -       newButton := ImageMorph new image: (World project makeThumbnail scaledToSize: 48@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@0;
>> >                 wrapCentering: #center;
>> >                 cellPositioning: #leftCenter;
>> >                 hResizing: #shrinkWrap;
>> >                 vResizing: #shrinkWrap;
>> >                 extent: 5@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!
>> >
>> >
>>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Hannes Hirzel
In reply to this post by David T. Lewis
On 11/14/17, David T. Lewis <[hidden email]> 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.

Note the wording 'unnecessary use of globals'

so in a Morph

    self world

is preferred to just

    World

>
> 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.

Great to see that you have started preparing to take this on again...

> 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,  <[hidden email]> 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@36).
>> > -       newButton := ImageMorph new image: (World project makeThumbnail
>> > scaledToSize: 48@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@0;
>> >                 wrapCentering: #center;
>> >                 cellPositioning: #leftCenter;
>> >                 hResizing: #shrinkWrap;
>> >                 vResizing: #shrinkWrap;
>> >                 extent: 5@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!
>> >
>> >
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

David T. Lewis
In reply to this post by Chris Muller-4
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.

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. 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 <[hidden email]> 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,  <[hidden email]> 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@36).
> >> > -       newButton := ImageMorph new image: (World project makeThumbnail scaledToSize: 48@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@0;
> >> >                 wrapCentering: #center;
> >> >                 cellPositioning: #leftCenter;
> >> >                 hResizing: #shrinkWrap;
> >> >                 vResizing: #shrinkWrap;
> >> >                 extent: 5@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!
> >> >
> >> >
> >>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Hannes Hirzel
On 11/14/17, David T. Lewis <[hidden email]> 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 <[hidden email]>
>> 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,  <[hidden email]> 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@36).
>> >> > -       newButton := ImageMorph new image: (World project
>> >> > makeThumbnail scaledToSize: 48@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@0;
>> >> >                 wrapCentering: #center;
>> >> >                 cellPositioning: #leftCenter;
>> >> >                 hResizing: #shrinkWrap;
>> >> >                 vResizing: #shrinkWrap;
>> >> >                 extent: 5@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!
>> >> >
>> >> >
>> >>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

marcel.taeumel
Hmm...  in our current use of Morphic, there is no difference between "World" and "ActiveWorld". Back then, "World" was the outermost world and "ActiveWorld" was the world that is involved in the particular event dispatch (see ActiveEvent, too), which could be in a window, for example. For everyday debugging, one should use "ActiveWorld" instead of "World". If we manage to get "worlds in worlds" working again (see Squeak 2.0 for example), "World" would not return the correct object anymore. It might be confusing.

Anyway, there is no need to completely remove World as such. Just remove all senders to it in application code. :)

Best,
Marcel

Am 14.11.2017 05:25:57 schrieb H. Hirzel <[hidden email]>:

On 11/14/17, David T. Lewis 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
>> 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, 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 <>
>> >> > 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@36).
>> >> > - newButton := ImageMorph new image: (World project
>> >> > makeThumbnail scaledToSize: 48@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@0;
>> >> > wrapCentering: #center;
>> >> > cellPositioning: #leftCenter;
>> >> > hResizing: #shrinkWrap;
>> >> > vResizing: #shrinkWrap;
>> >> > extent: 5@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!
>> >> >
>> >> >
>> >>
>>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Hannes Hirzel
On 11/14/17, Marcel Taeumel <[hidden email]> wrote:
> Hmm...  in our current use of Morphic, there is no difference between
> "World" and "ActiveWorld". Back then, "World" was the outermost world and
> "ActiveWorld" was the world that is involved in the particular event
> dispatch (see ActiveEvent, too), which could be in a window, for example.

Ok, here is the explanation for what I asked in the thread
    'ActiveWorld and World globals'

> For everyday debugging, one should use "ActiveWorld" instead of "World". If
> we manage to get "worlds in worlds" working again (see Squeak 2.0 for
> example), "World" would not return the correct object anymore. It might be
> confusing.

Thank you for referring to Squeak 2.0 where  "worlds in worlds" worked....

So I will continue with the thread ''ActiveWorld and World globals'

>
> Anyway, there is no need to completely remove World as such. Just remove all
> senders to it in application code. :)
>
> Best,
> Marcel
> Am 14.11.2017 05:25:57 schrieb H. Hirzel <[hidden email]>:
> On 11/14/17, David T. Lewis 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
>>> 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, 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 <>
>>> >> > 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@36).
>>> >> > - newButton := ImageMorph new image: (World project
>>> >> > makeThumbnail scaledToSize: 48@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@0;
>>> >> > wrapCentering: #center;
>>> >> > cellPositioning: #leftCenter;
>>> >> > hResizing: #shrinkWrap;
>>> >> > vResizing: #shrinkWrap;
>>> >> > extent: 5@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!
>>> >> >
>>> >> >
>>> >>
>>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Chris Muller-3
In reply to this post by marcel.taeumel
Shouldn't we be getting rid of ActiveWorld first then, instead of "World"?

Globals are fine when they're part of a set of "roots" or basic
objects to access to the system.  For example, "Smalltalk", or
"Transcript" or "Processor" or "World".

It's when we have globals that participate in "logic" (i.e., in this
case, "active" vs. inactive) which is the kind of bad-design global
that hurts the quality of the system.

 - Chris

On Tue, Nov 14, 2017 at 2:25 AM, Marcel Taeumel <[hidden email]> wrote:

> Hmm...  in our current use of Morphic, there is no difference between
> "World" and "ActiveWorld". Back then, "World" was the outermost world and
> "ActiveWorld" was the world that is involved in the particular event
> dispatch (see ActiveEvent, too), which could be in a window, for example.
> For everyday debugging, one should use "ActiveWorld" instead of "World". If
> we manage to get "worlds in worlds" working again (see Squeak 2.0 for
> example), "World" would not return the correct object anymore. It might be
> confusing.
>
> Anyway, there is no need to completely remove World as such. Just remove all
> senders to it in application code. :)
>
> Best,
> Marcel
>
> Am 14.11.2017 05:25:57 schrieb H. Hirzel <[hidden email]>:
>
> On 11/14/17, David T. Lewis 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
>>> 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, 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 <>
>>> >> > 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@36).
>>> >> > - newButton := ImageMorph new image: (World project
>>> >> > makeThumbnail scaledToSize: 48@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@0;
>>> >> > wrapCentering: #center;
>>> >> > cellPositioning: #leftCenter;
>>> >> > hResizing: #shrinkWrap;
>>> >> > vResizing: #shrinkWrap;
>>> >> > extent: 5@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!
>>> >> >
>>> >> >
>>> >>
>>>
>>
>>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

marcel.taeumel
The dynamically-scoped "ActiveWorld", which is technically not quite comparable with the global "World", is in line with ActiveEvent and ActiveHand. One would have to remove all three concepts.

"World", instead, is a duplicate of "Project current world".

Since we have to alternative for "ActiveWorld" at the moment, we cannot change it.

Best,
Marcel

Am 14.11.2017 18:31:10 schrieb Chris Muller <[hidden email]>:

Shouldn't we be getting rid of ActiveWorld first then, instead of "World"?

Globals are fine when they're part of a set of "roots" or basic
objects to access to the system. For example, "Smalltalk", or
"Transcript" or "Processor" or "World".

It's when we have globals that participate in "logic" (i.e., in this
case, "active" vs. inactive) which is the kind of bad-design global
that hurts the quality of the system.

- Chris

On Tue, Nov 14, 2017 at 2:25 AM, Marcel Taeumel wrote:
> Hmm... in our current use of Morphic, there is no difference between
> "World" and "ActiveWorld". Back then, "World" was the outermost world and
> "ActiveWorld" was the world that is involved in the particular event
> dispatch (see ActiveEvent, too), which could be in a window, for example.
> For everyday debugging, one should use "ActiveWorld" instead of "World". If
> we manage to get "worlds in worlds" working again (see Squeak 2.0 for
> example), "World" would not return the correct object anymore. It might be
> confusing.
>
> Anyway, there is no need to completely remove World as such. Just remove all
> senders to it in application code. :)
>
> Best,
> Marcel
>
> Am 14.11.2017 05:25:57 schrieb H. Hirzel :
>
> On 11/14/17, David T. Lewis 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
>>> 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, 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 <>
>>> >> > 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@36).
>>> >> > - newButton := ImageMorph new image: (World project
>>> >> > makeThumbnail scaledToSize: 48@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@0;
>>> >> > wrapCentering: #center;
>>> >> > cellPositioning: #leftCenter;
>>> >> > hResizing: #shrinkWrap;
>>> >> > vResizing: #shrinkWrap;
>>> >> > extent: 5@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!
>>> >> >
>>> >> >
>>> >>
>>>
>>
>>
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

marcel.taeumel
Oh, sorry. I mean that we have _NO_ alternative for "ActiveWorld" at the moment.

Best,
Marcel

Am 14.11.2017 19:37:08 schrieb Marcel Taeumel <[hidden email]>:

The dynamically-scoped "ActiveWorld", which is technically not quite comparable with the global "World", is in line with ActiveEvent and ActiveHand. One would have to remove all three concepts.

"World", instead, is a duplicate of "Project current world".

Since we have to alternative for "ActiveWorld" at the moment, we cannot change it.

Best,
Marcel

Am 14.11.2017 18:31:10 schrieb Chris Muller <[hidden email]>:

Shouldn't we be getting rid of ActiveWorld first then, instead of "World"?

Globals are fine when they're part of a set of "roots" or basic
objects to access to the system. For example, "Smalltalk", or
"Transcript" or "Processor" or "World".

It's when we have globals that participate in "logic" (i.e., in this
case, "active" vs. inactive) which is the kind of bad-design global
that hurts the quality of the system.

- Chris

On Tue, Nov 14, 2017 at 2:25 AM, Marcel Taeumel wrote:
> Hmm... in our current use of Morphic, there is no difference between
> "World" and "ActiveWorld". Back then, "World" was the outermost world and
> "ActiveWorld" was the world that is involved in the particular event
> dispatch (see ActiveEvent, too), which could be in a window, for example.
> For everyday debugging, one should use "ActiveWorld" instead of "World". If
> we manage to get "worlds in worlds" working again (see Squeak 2.0 for
> example), "World" would not return the correct object anymore. It might be
> confusing.
>
> Anyway, there is no need to completely remove World as such. Just remove all
> senders to it in application code. :)
>
> Best,
> Marcel
>
> Am 14.11.2017 05:25:57 schrieb H. Hirzel :
>
> On 11/14/17, David T. Lewis 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
>>> 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, 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 <>
>>> >> > 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@36).
>>> >> > - newButton := ImageMorph new image: (World project
>>> >> > makeThumbnail scaledToSize: 48@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@0;
>>> >> > wrapCentering: #center;
>>> >> > cellPositioning: #leftCenter;
>>> >> > hResizing: #shrinkWrap;
>>> >> > vResizing: #shrinkWrap;
>>> >> > extent: 5@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!
>>> >> >
>>> >> >
>>> >>
>>>
>>
>>
>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

Chris Muller-4
In reply to this post by marcel.taeumel
On Tue, Nov 14, 2017 at 12:37 PM, Marcel Taeumel <[hidden email]> wrote:
> The dynamically-scoped "ActiveWorld", which is technically not quite
> comparable with the global "World", is in line with ActiveEvent and
> ActiveHand. One would have to remove all three concepts.

Okay, and just to be clear, I'm not really pushing for any removals or
non-removals as much as just trying to understand our policy toward
globals.

I see Dynamic vars as similar to globals in terms of being a
read/write free-for-all, not scoped by the code structure, but by
runtime conditions as well, which imposes an even greater cognitive
load on the reader than a simple global.  I know they have their
use-case, but besides that, I do hope we'll steer clear of introducing
any more DynamicVars into the base code.

Best,
  Chris

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

marcel.taeumel
Agreed. One shoud avoid writing code that uses "ActiveWorld" or even "Project current world" for that matter. It can only be a "last choice". Still, having it as a handy mechanism at the programmer's disposal, well, I find that quite valuable.

Comparing "World" against "ActiveWorld", I would say that "World"-use needs more attention right now. :)

Best,
Marcel 

Am 14.11.2017 20:37:12 schrieb Chris Muller <[hidden email]>:

On Tue, Nov 14, 2017 at 12:37 PM, Marcel Taeumel wrote:
> The dynamically-scoped "ActiveWorld", which is technically not quite
> comparable with the global "World", is in line with ActiveEvent and
> ActiveHand. One would have to remove all three concepts.

Okay, and just to be clear, I'm not really pushing for any removals or
non-removals as much as just trying to understand our policy toward
globals.

I see Dynamic vars as similar to globals in terms of being a
read/write free-for-all, not scoped by the code structure, but by
runtime conditions as well, which imposes an even greater cognitive
load on the reader than a simple global. I know they have their
use-case, but besides that, I do hope we'll steer clear of introducing
any more DynamicVars into the base code.

Best,
Chris


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: MorphicExtras-dtl.214.mcz

K K Subbu
In reply to this post by Chris Muller-4
On Wednesday 15 November 2017 01:06 AM, Chris Muller wrote:
> I see Dynamic vars as similar to globals in terms of being a
> read/write free-for-all, not scoped by the code structure, but by
> runtime conditions as well, which imposes an even greater cognitive
> load on the reader than a simple global.  I know they have their
> use-case, but besides that, I do hope we'll steer clear of introducing
> any more DynamicVars into the base code.

Dynamic vars (like the keywords self and super) have their uses,
particularly when working with sensors.

Using variables like "Now" is more readable than "DateAndTime now
ticks". There should a facility in base code to tag such variables as
aliases.

E.g.

   AliasBuilder new:#World for: [Project current world]

   AliasBuilder new:#Now for: [DateAndTime now ticks]

The compiler can then replace every reference to Now with:

   ([AliasBuilder lookup:#Now] value)

Regards .. Subbu