[squeak-dev] The Trunk: Environments-dtl.72.mcz

David T. Lewis lewis at mail.msen.com
Sun Mar 18 16:10:39 UTC 2018


On Sun, Mar 18, 2018 at 09:02:13AM -0700, Eliot Miranda wrote:
> Hi Jacob,
> 
> > On Mar 18, 2018, at 3:40 AM, Jakob Reschke <forums.jakob at resfarm.de> wrote:
> > 
> > Hi Eliot,
> > 
> > Note that self bindings select: is not the same as self select: for an
> > Environment, as the latter only enumerates the declarations (its "own"
> > bindings).
> > 
> > Seems like the only sender is Class rootsOfTheWorld, which itself is
> > unsent. In that case, the Smalltalk "root" environment is hard-coded
> > and the specifics of bindings vs. declarations do not really matter.
> > But what should #rootClasses answer for other, possibly isolated
> > environments? What does the sender want to know?
> > - For an empty environment (no classes contained), should it answer an
> > empty collection?
> 
> Yes
> 
> > - Should the answer change if the "root" environment is imported?
> 
> No
> 
> > - For an environment that a) does not contain ProtoObject or Object,
> > but other classes deriving from them, and b) does not import the
> > "root" environment, should it answer an empty collection,
> > {ProtoObject} (although it is not imported) via superclass relations,
> > or something else?
> 
> Empty
> 
> > - Should the answer change if the "root" environment is imported?
> > 
> > By the way, would it work to have a second (different) ProtoObject
> > class in the image (in a different environment or under a different
> > name)?
> 
> It should, right?
> 
> the rootsOfTheWorld are easy to understand and hence to extend to environments.  Pre environments theRootsOfTheWorld are the classes that have no superclass (have nil as their superclass).  theRootsOfTheWorld is a set (has no duplicates) but can be a sequence.  Hence, given that Smalltalk can contain user defined variables, and the values of these variables can be anything, including classes, the computation of theRootsOfTheWorld should filter out variables that just happen to refer to root classes to ensure that a set is answered.
> 
> Extending this to environments then is straight forward.  theRootsOfTheWorld in an environment is a set of the classes defined in that environment that have no superclass. The computation should not be confusable by variables whose values just happen to be toot classes.
> 
> Now, given that theRootsOfTheWorld are used as the roots of code search (allImplementosOf: et al) the notion of a pet-environment theRootsOfTheWorld is suspect, given that code search should be able to search all code.  But let's at least get the per-environment definition correct before we try and define a system-wide one.
> 

And just for historial background:

Markus added Class class>>rootsOfTheWorld in Squeak 3.9, along with
ClassTest>>testRootsOfTheWorld which was its only sender. At that time:

  Class rootsOfTheWorld
      ==> an OrderedCollection(ObjectTracer PseudoContext ProtoObject)

In 2013, Frank moved the logic into Environment>>rootClasses because
Smalltalk globals is now an Environment.

With the current updates, I moved Frank's submission from inbox to trunk,
and updated #rootsOfTheWorld to call #rootClasses rather than duplicate
the code.

Somewhere along the way #testRootsOfTheWorld went away, and we now have:

  Class rootsOfTheWorld
     ==> an OrderedCollection(ProtoObject)

In Pharo, #rootsOfTheWorld is sent by RBNamespace, and there are no Environments.

Dave


> > 
> > Best regards,
> > Jakob
> > 
> > 2018-03-18 9:18 GMT+01:00 Eliot Miranda <eliot.miranda at gmail.com>:
> >> Hi David,
> >> 
> >>>> On Mar 17, 2018, at 8:19 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> >>>> 
> >>>> On Sat, Mar 17, 2018 at 04:54:36PM -0700, Eliot Miranda wrote:
> >>>> Hi David,
> >>>> 
> >>>>> On Sat, Mar 17, 2018 at 12:10 PM, <commits at source.squeak.org> wrote:
> >>>>> 
> >>>>> David T. Lewis uploaded a new version of Environments to project The Trunk:
> >>>>> http://source.squeak.org/trunk/Environments-dtl.72.mcz
> >>>>> 
> >>>>> ==================== Summary ====================
> >>>>> 
> >>>>> Name: Environments-dtl.72
> >>>>> Author: dtl
> >>>>> Time: 17 March 2018, 3:09:49.564301 pm
> >>>>> UUID: e9aed004-8798-41c0-83f9-a04f5963dd55
> >>>>> Ancestors: Environments-jr.71, Environments-fbs.27
> >>>>> 
> >>>>> Merge Environments-fbs.27
> >>>>> 
> >>>>> =============== Diff against Environments-jr.71 ===============
> >>>>> 
> >>>>> Item was added:
> >>>>> + ----- Method: Environment>>rootClasses (in category 'accessing') -----
> >>>>> + rootClasses
> >>>>> +       "return a collection of classes which have a nil superclass"
> >>>>> +       ^ (self select: [:each | each isBehavior and: [each superclass
> >>>>> isNil]]) asOrderedCollection.!
> >>>>> 
> >>>> 
> >>>> At least for me this isn't quite good enough.  There's a possibility that
> >>>> someone could establish a variable whose value is a root, e.g. by
> >>>> 
> >>>> Smalltalk at: #MyRootClass put: ProtoObject
> >>>> 
> >>>> and that would cause rootClasses to answer a duplicate.  So IMO it needs to
> >>>> do one of
> >>>> - convert to a set and then back to a collection
> >>>> - answer a set
> >>>> - enumerate over associations, selecting those classes whose key is the
> >>>> same as their name
> >>>> 
> >>>> _,,,^..^,,,_
> >>>> best, Eliot
> >>> 
> >>> Hi Eliot,
> >>> 
> >>> Do you mean this?
> >>> 
> >>> Environment>>rootClasses
> >>>   "return a collection of classes which have a nil superclass"
> >>>   ^ (self select: [:each | each isBehavior and: [each superclass isNil]]) asSet asOrderedCollection.
> >> 
> >> That'll do but perhaps better is
> >> 
> >>          self bindings select: [:each | each value isBehavior and: [each value superclass isNil and: [each value name == each key]]]) collect:  [:each | each value]
> >> 
> >>> 
> >>> 
> >>> Note, I am not the author here, just tending to the inbox :-)
> >>> 
> >>> Thanks,
> >>> Dave
> >>> 
> >>> 
> >> 
> > 
> 


More information about the Squeak-dev mailing list