[squeak-dev] [ANN] DoItFirst command line goodie on SqueakSource

David T. Lewis lewis at mail.msen.com
Sun Dec 6 17:52:39 UTC 2020

On Sat, Dec 05, 2020 at 09:33:26AM +0100, Fabio Niephaus wrote:
> This is great! +1 for adding this to trunk, leaving the when to Dave.
> Two thoughts:
> - Since you've started to "mess" with some #startUp: methods, why not mess
> with the startUp routine as well? Let's say, you add a flag that lists all
> items in the startUpList and quits the image. You can then add another flag
> that lets you choose the position of the DoItFirst class within the
> list, and insert the class right before processing it (e.g.
> #processStartUpList:). And by default, the position could be set to some
> reasonable value (right after SmallInteger, FileStream, et al.). If I don't
> care about the position, I can just use the default. If I want a special
> position, I can print the current list and then rerun with an index.

The way I handled this is by making DoItFirst be the first entry in the
startup list, and having it invoke the startUp in other classes if and only
if needed to process the command line options. The rationale for this
is that the --debug option will enter a debugger at the earliest possible
time before encountering any errors that might occur later in the
startUp processing. This is a feature that you don't need very often,
but when you need it, you really need it.

> - I don't know how yet, but it'd be cool to be able to cut off the rest of
> the startUp list with this utility, or exclude certain classes from the
> startUp list. In TruffleSqueak, for example, we jump through some hoops to
> set up an image for headless execution [1] and it'd be nice if we could
> simplify that with your utility.

That might be a tricky problem, but I'm sure it can be done. In principle
we could manipulate the startup from one of the existing argument hooks,
but at that point we are already iterating over the startup list so
it is presumably not good to manipulate the list at that time. One
possible solution that comes to mind is to move DoItFirst out of the
startup list, and just explictly call it right before processing the

I note also that we do not have accessors for the StartUpList and ShutDownList,
so we would probably want to add these too.


> Cheers,
> Fabio
> [1]
> https://github.com/hpi-swa/trufflesqueak/blob/4aa371a608bd73e9be1a6c65e727eb45370d23e8/src/de.hpi.swa.trufflesqueak/src/de/hpi/swa/trufflesqueak/image/SqueakImageContext.java#L191-L207
> On Thu, Nov 26, 2020 at 9:01 PM David T. Lewis <lewis at mail.msen.com> wrote:
> > On Sun, Jun 14, 2020 at 01:15:01PM -0400, David T. Lewis wrote:
> > > A few cups of coffee this morning led to some enhancements to my
> > DoItFirst
> > > utility, so I decided to put in on SqueakSource.
> > >
> > >    http://www.squeaksource.com/DoItFirst
> > >
> >
> > I have been updating this since the original post, and I think it is
> > in pretty good shape at this point. Latest version on SqueakSource is
> > DoItFirst-System-Support-dtl.14.mcz.
> >
> > In order to make this work properly I also add a couple of references
> > to DoItFirst from other class startUp methods. That is messy to add to
> > a MCZ, so I'm attaching a change set containing the latest package plus
> > the two additional startUp calls.
> >
> > I think this is clean enough to consider adding to trunk now, so if
> > folks think it is a good idea, let me know and I'll add it.
> >
> > To summarize (from the -help command line option):
> >
> > DoItFirst image arguments:
> >         -doit argumentlist "evaluate each argument as a doIt expression"
> >         -evaluate arg "evaluate arg, print result then exit"
> >         -filein filelist "file in each file named in fileList"
> >         -cwd path "set FileDirectory defaultDirectory to path prior to
> > evaluating other options"
> >         -debug "enter a debugger as soon as possible in the startUp
> > processing"
> >         -help "print this message"
> >
> > Dave
> >
> >
> >


More information about the Squeak-dev mailing list