The Inbox: System-dtl.1164.mcz

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

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
On Wed, Jun 10, 2020 at 05:07:53PM -0700, Eliot Miranda wrote:

>
>
> > On Jun 9, 2020, at 8:44 PM, Chris Muller <[hidden email]> wrote:
> >
> > ???
> >> > On 2020-06-09, at 11:52 AM, David T. Lewis <[hidden email]> wrote:
> >> >
> >> > Funny you should mention it, that's how I went down this rabbit hole
> >> > in the first place. I was thinking that it would be an obviously good
> >> > thing to do if we could evaluate a doIt or named script file immediately
> >> > on image startup, as opposed to waiting until all of the Etoys script
> >> > processing comes to life somewhere later in the startUp process.
> >>
> >> Exactly. Note that VW has several commandline switches we might want to learn from
> >>
> >> -filein {some file names}
> >> -doit {some strings}
> >> -evaluate {a single string & write result to stdout & quit
> >> -cli {start a commandline loop}
> >
> > What I most like about Dave's change is the improved separation of concerns:  it allows the OS to invoke an image with the proper startup script and/or arguments WITHOUT relying on Preferences readDocumentAtStartup being set correctly.  I can see -filein being useful for a production patch use-case, but the rest of those go back to mixing the Smalltalk environment in with the operating-system environment.  For safe and scalable headless interaction, you would just use a server.  I never knew if there was an actual use-case for -evaluate and -cli other than novelty.  Is there?
>
> Both are useful for testing. ???evaluate is useful in eg a (unix software build style) configure context.  ???cli is useful for people who want to explore, learn, demo, etc.  
>
> But since they don???t really cost much why are you bothering to try and veto them?
>

I didn't read Chris' question as a veto, just a bit of possibly justified
skepticism. But all four of these proposed options should be quite easy to
implement, so there's no reason not to try them :-)

Dave


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

Chris Muller-4
In reply to this post by Eliot Miranda-2
Hi Eliot, 

As far as I know, only top-ranking executives can veto something, not peons.  :)  As always, my ideas are presented as from one peer to another.  I know you wouldn't advocate for needless feature-creep, and Dave referred to them as an "obviously good thing to do", so my curiosity was piqued.

I've noticed myself launching Squeak for when I simply want a calculator because it launches 10X faster than the "Calculator" app of the OS.   -cli would be nice for that..  :)

 - Chris

On Wed, Jun 10, 2020 at 7:07 PM Eliot Miranda <[hidden email]> wrote:


On Jun 9, 2020, at 8:44 PM, Chris Muller <[hidden email]> wrote:


> On 2020-06-09, at 11:52 AM, David T. Lewis <[hidden email]> wrote:
>
> Funny you should mention it, that's how I went down this rabbit hole
> in the first place. I was thinking that it would be an obviously good
> thing to do if we could evaluate a doIt or named script file immediately
> on image startup, as opposed to waiting until all of the Etoys script
> processing comes to life somewhere later in the startUp process.

Exactly. Note that VW has several commandline switches we might want to learn from

-filein {some file names}
-doit {some strings}
-evaluate {a single string & write result to stdout & quit
-cli {start a commandline loop}

What I most like about Dave's change is the improved separation of concerns:  it allows the OS to invoke an image with the proper startup script and/or arguments WITHOUT relying on Preferences readDocumentAtStartup being set correctly.  I can see -filein being useful for a production patch use-case, but the rest of those go back to mixing the Smalltalk environment in with the operating-system environment.  For safe and scalable headless interaction, you would just use a server.  I never knew if there was an actual use-case for -evaluate and -cli other than novelty.  Is there?

Both are useful for testing. —evaluate is useful in eg a (unix software build style) configure context.  —cli is useful for people who want to explore, learn, demo, etc.  

But since they don’t really cost much why are you bothering to try and veto them?


 - Chris



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
In reply to this post by David T. Lewis
Note to self: The #rawArguments method should be private, follow up
in a future update.

If anyone is getting ready to push something for System to the trunk,
can you please also move SmalltalkImage>>rawArguments to method
category 'private'?

Thanks,
Dave

On Wed, Jun 10, 2020 at 11:58:03AM -0400, David T. Lewis wrote:

> On Wed, Jun 10, 2020 at 06:15:53PM +0530, K K Subbu wrote:
> > On 09/06/20 8:03 pm, David T. Lewis wrote:
> > >At this point, I am not trying to add any new features. I just want to
> > >get the existing argument handling to work consistent with the original
> > >design intent, and also consistently with respect to the various ways in
> > >which a user might enter a command line from a terminal window.
> > Dave,
> >
> > I wasn't trying to suggest any new feature. I got misled by the name
> > rawArguments. I overlooked its comments that stated that vm options are
> > removed.
> >
> > * could this be renamed into imageArguments?
> > * we could use 'nil' to skip startup document.
> >
> > Both these changes will sync the selector with the comments. It would
> > also dissuade people from putting startup code in a file named 'nil' ;-).
> >
>
> The SmalltalkImage>>rawArguments method should probably be private. I only
> added it to shorten the SmalltalkImage>>arguments method. But if it's
> confusing, we can get rid of it, or just hide it in a private category.
>
> Dave
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
In reply to this post by timrowledge
Hi Tim,

On Tue, Jun 09, 2020 at 12:06:00PM -0700, tim Rowledge wrote:

>
>
> > On 2020-06-09, at 11:52 AM, David T. Lewis <[hidden email]> wrote:
> >
> > Funny you should mention it, that's how I went down this rabbit hole
> > in the first place. I was thinking that it would be an obviously good
> > thing to do if we could evaluate a doIt or named script file immediately
> > on image startup, as opposed to waiting until all of the Etoys script
> > processing comes to life somewhere later in the startUp process.
>
> Exactly. Note that VW has several commandline switches we might want to learn from
>
> -filein {some file names}
> -doit {some strings}
> -evaluate {a single string & write result to stdout & quit
> -cli {start a commandline loop}
>
Attached is a quick and dirty implementation than handles -filein, -doit, and -evaluate.

Dave
 



DoItFirst-dtl.1.cs (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
It works pretty well actually:

$ time run squeak -- -evaluate "(3 + 4 + Float pi cubed) asScaledDecimal: 20"
38.00627668029981975905s20

real 0m0.134s
user 0m0.054s
sys 0m0.088s



On Fri, Jun 12, 2020 at 03:41:34PM -0400, David T. Lewis wrote:

> Hi Tim,
>
> On Tue, Jun 09, 2020 at 12:06:00PM -0700, tim Rowledge wrote:
> >
> >
> > > On 2020-06-09, at 11:52 AM, David T. Lewis <[hidden email]> wrote:
> > >
> > > Funny you should mention it, that's how I went down this rabbit hole
> > > in the first place. I was thinking that it would be an obviously good
> > > thing to do if we could evaluate a doIt or named script file immediately
> > > on image startup, as opposed to waiting until all of the Etoys script
> > > processing comes to life somewhere later in the startUp process.
> >
> > Exactly. Note that VW has several commandline switches we might want to learn from
> >
> > -filein {some file names}
> > -doit {some strings}
> > -evaluate {a single string & write result to stdout & quit
> > -cli {start a commandline loop}
> >
>
> Attached is a quick and dirty implementation than handles -filein, -doit, and -evaluate.
>
> Dave
>  

> 'From Squeak6.0alpha of 8 June 2020 [latest update: #19714] on 12 June 2020 at 3:38:05 pm'! "Change Set: DoItFirst-dtl Date: 12 June 2020 Author: David T Lewis Be the first thing in the system startup list, and do things that should be done prior to any additional image initialization. If the first image argument is a recognized option, evalutate it. Image arguments are typically preceeded by a '--' token on the command line. Possible command options:   -filein {some file names}   -doit {some strings}   -evaluate {a single string & write result to stdout & quit"! !DoItFirst commentStamp: 'dtl 6/12/2020 15:34' prior: 0! Be the first thing in the system startup list, and do things that should be done prior to any additional image initialization. If the first image argument is a recognized option, evalutate it. Image arguments are typically preceeded by a '--' token on the command line. Possible command options:   -filein {some file names}   -doit {some strings}   -evaluate {a single string & write result to stdout & quit ! !DoItFirst class methodsFor: 'class initialization' stamp: 'dtl 6/11/2020 18:42'! initialize "DoItFirst initialize" Smalltalk addToStartUpList: self before: SmallInteger.! ! !DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 14:41'! doIt: arguments "Evaluate arguments and print the result on stdout, or error message on stderr. Exit the image after any error." FileStream startUp: true. arguments do: [ :arg | [FileStream stdout nextPutAll: (Compiler evaluate: arg) asString; lf; flush] on: Error do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush. Smalltalk quitPrimitive ]]! ! !DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 14:35'! evaluate: arg "Evaluate arg and print the result on stdout, or error message on stderr. Exit immediately without saving the image." FileStream startUp: true. [FileStream stdout nextPutAll: (Compiler evaluate: arg) asString; lf; flush] on: Error do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush ]. Smalltalk quitPrimitive! ! !DoItFirst class methodsFor: 'actions' stamp: 'dtl 6/12/2020 15:28'! fileIn: fileNames "File in each named file. On error, print a message to stderr and exit the image." FileStream startUp: true. fileNames do: [ :arg | [ | fs | fs := FileStream oldFileNamed: arg. FileStream stdout nextPutAll: 'fiie in ', fs asString; lf; flush. fs fileIn ] on: Error do: [ :ex | FileStream stderr nextPutAll: ex asString; lf; flush. Smalltalk quitPrimitive ]]! ! !DoItFirst class methodsFor: 'system startup' stamp: 'dtl 6/12/2020 14:47'! startUp: resuming resuming ifTrue: [ | args | args := Smalltalk arguments. args size > 1 ifTrue: [ args first caseOf: { [ '-doit' ] -> [ self doIt: args allButFirst ] . [ '--doit' ] -> [ self doIt: args allButFirst ] . [ '-evaluate' ] -> [ self evaluate: args second ] . [ '--evaluate' ] -> [ self evaluate: args second ] . [ '-filein' ] -> [ self fileIn: args allButFirst ] . [ '--filein' ] -> [ self fileIn: args allButFirst ] } otherwise: []]] ! ! DoItFirst initialize!
>


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

timrowledge
Erk - the changeset you posted doesn't include the class definition and so fails to load. Which makes it really hard to try out...

> On 2020-06-12, at 2:04 PM, David T. Lewis <[hidden email]> wrote:
>
> It works pretty well actually:


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Strange OpCodes: HCF: Halt and Catch Fire



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
That's odd. I filed the class in to a new change set, and end up
with no class definition in the change set, that can't be right.

Updated change set attached.

Dave


On Fri, Jun 12, 2020 at 02:09:52PM -0700, tim Rowledge wrote:

> Erk - the changeset you posted doesn't include the class definition and so fails to load. Which makes it really hard to try out...
>
> > On 2020-06-12, at 2:04 PM, David T. Lewis <[hidden email]> wrote:
> >
> > It works pretty well actually:
>
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Strange OpCodes: HCF: Halt and Catch Fire
>
>
>



DoItFirst-dtl.2.cs (3K) Download Attachment
DoItFirst.st (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

timrowledge
OK, the DoItFirst-dtl.2.cs filed in ok. It did however make the image save suddenly take a very long time  - but after save/quit and restartin the save no longer takes ages. Weird.

I had to execute -

 time  /home/pi/Documents/Squeak/sqcogspurlinuxhtRPi/squeak /home/pi/Documents/Squeak/CmdLineTests-TPR-Squeak5.3-19682-32bit.image  -- -evaluate "(3 + 4 + Float pi cubed) asScaledDecimal: 20"
38.00627668029981975905s20

real 0m0.393s
user 0m0.086s
sys 0m0.283s

a) no idea what the 'run' command might be and it is not on Raspbian
b) I'm guessing your 'squeak' script was finding the default named image?
c) that time was for a Pi 4, which took about 3x as long as what I image is probably a reasonably modern x64 box? The registered user time was less than double though. Not bad for $35.

I must be doing something wrong when I tried the -doit option though; it faults in CodeLoader>>installSourceFile: Apparently sometihng has lead it to see an HTTPDownloadRequest ... ok, so the ProjectLauncher>>startUpAfterLogin sees that Preferences readDocumentAtStartup is true and that makes the unwarranted assumption that self getSystemAttribute: 2 will provide the document path. Oops.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
If you think nobody cares about you, try missing a couple of payments.



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
Oh, sorry, the "run" command is my /usr/local/bin/run script that picks
a suitable VM. The effect is the same as running the VM executable directly,
so run the VM in whatever manner you like. I am in the habit of installing
my user executables (the VM run scripts in this case) in /usr/local/bin/ so
that they will be in my $PATH.

Here is what a -doit looks like on my PC. It evaluates the doIt argument,
and once the image opens you can see the #FOO has been added to the system
dictionary.

$ run squeak -- -doit "Smalltalk at: #FOO put: #BAR"
BAR

Note the ' -- ' before the '-doit'. However you might decide to invoke
the command line, you can put ' -- ' before the arguments and they
should get get passed along to the image.

Note that this hack is doing the evaluations as the very first thing
in the startUp sequence, so if you evaluate something that (for example)
opens an inspector, that inspector is not necessarily going to place
itself properly in the Morphic world. But it does seem to work, and
being able to do something like this before anything else gets screwed
up in the startUp processing might be a handy thing to be able to do.

Dave


On Fri, Jun 12, 2020 at 03:07:43PM -0700, tim Rowledge wrote:

> OK, the DoItFirst-dtl.2.cs filed in ok. It did however make the image save suddenly take a very long time  - but after save/quit and restartin the save no longer takes ages. Weird.
>
> I had to execute -
>
>  time  /home/pi/Documents/Squeak/sqcogspurlinuxhtRPi/squeak /home/pi/Documents/Squeak/CmdLineTests-TPR-Squeak5.3-19682-32bit.image  -- -evaluate "(3 + 4 + Float pi cubed) asScaledDecimal: 20"
> 38.00627668029981975905s20
>
> real 0m0.393s
> user 0m0.086s
> sys 0m0.283s
>
> a) no idea what the 'run' command might be and it is not on Raspbian
> b) I'm guessing your 'squeak' script was finding the default named image?
> c) that time was for a Pi 4, which took about 3x as long as what I image is probably a reasonably modern x64 box? The registered user time was less than double though. Not bad for $35.
>
> I must be doing something wrong when I tried the -doit option though; it faults in CodeLoader>>installSourceFile: Apparently sometihng has lead it to see an HTTPDownloadRequest ... ok, so the ProjectLauncher>>startUpAfterLogin sees that Preferences readDocumentAtStartup is true and that makes the unwarranted assumption that self getSystemAttribute: 2 will provide the document path. Oops.
>
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> If you think nobody cares about you, try missing a couple of payments.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

timrowledge
Am I remembering right that you mentioned sometihng about disabling the readDocuments stuff?

> On 2020-06-12, at 4:31 PM, David T. Lewis <[hidden email]> wrote:
>
> Oh, sorry, the "run" command is my /usr/local/bin/run script that picks
> a suitable VM. The effect is the same as running the VM executable directly,
> so run the VM in whatever manner you like. I am in the habit of installing
> my user executables (the VM run scripts in this case) in /usr/local/bin/ so
> that they will be in my $PATH.
>
> Here is what a -doit looks like on my PC. It evaluates the doIt argument,
> and once the image opens you can see the #FOO has been added to the system
> dictionary.
>
> $ run squeak -- -doit "Smalltalk at: #FOO put: #BAR"
> BAR
>
> Note the ' -- ' before the '-doit'. However you might decide to invoke
> the command line, you can put ' -- ' before the arguments and they
> should get get passed along to the image.
>
> Note that this hack is doing the evaluations as the very first thing
> in the startUp sequence, so if you evaluate something that (for example)
> opens an inspector, that inspector is not necessarily going to place
> itself properly in the Morphic world. But it does seem to work, and
> being able to do something like this before anything else gets screwed
> up in the startUp processing might be a handy thing to be able to do.
>
> Dave
>
>
> On Fri, Jun 12, 2020 at 03:07:43PM -0700, tim Rowledge wrote:
>> OK, the DoItFirst-dtl.2.cs filed in ok. It did however make the image save suddenly take a very long time  - but after save/quit and restartin the save no longer takes ages. Weird.
>>
>> I had to execute -
>>
>> time  /home/pi/Documents/Squeak/sqcogspurlinuxhtRPi/squeak /home/pi/Documents/Squeak/CmdLineTests-TPR-Squeak5.3-19682-32bit.image  -- -evaluate "(3 + 4 + Float pi cubed) asScaledDecimal: 20"
>> 38.00627668029981975905s20
>>
>> real 0m0.393s
>> user 0m0.086s
>> sys 0m0.283s
>>
>> a) no idea what the 'run' command might be and it is not on Raspbian
>> b) I'm guessing your 'squeak' script was finding the default named image?
>> c) that time was for a Pi 4, which took about 3x as long as what I image is probably a reasonably modern x64 box? The registered user time was less than double though. Not bad for $35.
>>
>> I must be doing something wrong when I tried the -doit option though; it faults in CodeLoader>>installSourceFile: Apparently sometihng has lead it to see an HTTPDownloadRequest ... ok, so the ProjectLauncher>>startUpAfterLogin sees that Preferences readDocumentAtStartup is true and that makes the unwarranted assumption that self getSystemAttribute: 2 will provide the document path. Oops.
>>
>>
>> tim
>> --
>> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
>> If you think nobody cares about you, try missing a couple of payments.
>>
>>
>>
>
>


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- Overdue for deincarnation.



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

David T. Lewis
On Fri, Jun 12, 2020 at 04:37:59PM -0700, tim Rowledge wrote:
> Am I remembering right that you mentioned sometihng about disabling the readDocuments stuff?
>

I had been thinking that it might be possible to do that, but I was
mistaken. The readDocumentAtStartup preference is still in place.

Unfortunately, what I *did* do is introduce a bug in #arguments when the
preference is disabled. It should be fixed now in System-dtl.1165.

If you have the preference disabled, you should now be able to do something
like this:

$ squeak squeak.image -evaluate '3 + 4'
7


Dave

> > On 2020-06-12, at 4:31 PM, David T. Lewis <[hidden email]> wrote:
> >
> > Oh, sorry, the "run" command is my /usr/local/bin/run script that picks
> > a suitable VM. The effect is the same as running the VM executable directly,
> > so run the VM in whatever manner you like. I am in the habit of installing
> > my user executables (the VM run scripts in this case) in /usr/local/bin/ so
> > that they will be in my $PATH.
> >
> > Here is what a -doit looks like on my PC. It evaluates the doIt argument,
> > and once the image opens you can see the #FOO has been added to the system
> > dictionary.
> >
> > $ run squeak -- -doit "Smalltalk at: #FOO put: #BAR"
> > BAR
> >
> > Note the ' -- ' before the '-doit'. However you might decide to invoke
> > the command line, you can put ' -- ' before the arguments and they
> > should get get passed along to the image.
> >
> > Note that this hack is doing the evaluations as the very first thing
> > in the startUp sequence, so if you evaluate something that (for example)
> > opens an inspector, that inspector is not necessarily going to place
> > itself properly in the Morphic world. But it does seem to work, and
> > being able to do something like this before anything else gets screwed
> > up in the startUp processing might be a handy thing to be able to do.
> >
> > Dave
> >
> >
> > On Fri, Jun 12, 2020 at 03:07:43PM -0700, tim Rowledge wrote:
> >> OK, the DoItFirst-dtl.2.cs filed in ok. It did however make the image save suddenly take a very long time  - but after save/quit and restartin the save no longer takes ages. Weird.
> >>
> >> I had to execute -
> >>
> >> time  /home/pi/Documents/Squeak/sqcogspurlinuxhtRPi/squeak /home/pi/Documents/Squeak/CmdLineTests-TPR-Squeak5.3-19682-32bit.image  -- -evaluate "(3 + 4 + Float pi cubed) asScaledDecimal: 20"
> >> 38.00627668029981975905s20
> >>
> >> real 0m0.393s
> >> user 0m0.086s
> >> sys 0m0.283s
> >>
> >> a) no idea what the 'run' command might be and it is not on Raspbian
> >> b) I'm guessing your 'squeak' script was finding the default named image?
> >> c) that time was for a Pi 4, which took about 3x as long as what I image is probably a reasonably modern x64 box? The registered user time was less than double though. Not bad for $35.
> >>
> >> I must be doing something wrong when I tried the -doit option though; it faults in CodeLoader>>installSourceFile: Apparently sometihng has lead it to see an HTTPDownloadRequest ... ok, so the ProjectLauncher>>startUpAfterLogin sees that Preferences readDocumentAtStartup is true and that makes the unwarranted assumption that self getSystemAttribute: 2 will provide the document path. Oops.
> >>
> >>
> >> tim
> >> --
> >> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> >> If you think nobody cares about you, try missing a couple of payments.
> >>
> >>
> >>
> >
> >
>
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Useful random insult:- Overdue for deincarnation.
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1164.mcz

timrowledge
Taking a quick look at the usages of getSystemAttribute: shows that we need some cleanup there, which ought to help make this doit etc work better.

There is a ridiculous assumption that the name of the document to load must be item 2, and that item 3 must be to do with Russian/Japanese language environment handling. Quite what one is supposed to do if no initial document is needed but Japanese is required...

If we could extend the parsing in DoItFIrst a little we ought to be able to work out whether there is a string intended as the name of a document and store it suitable. Modifying the SmalltalkImage>documentPath method suitably shouldn't be beyond our skills.

An interesting question is what to do about mixing these options. Obviously an `evaluate` will stop things at its end but  would it make any sense to allow

squeak vmOpt vmOp2 imagename -doit "Filename setWorkingDirectory:'/foo/bar'" documentToReadPathRelativeToCWD

with the expectation that it would start, set the cwd, then read the doc based on a path relative to the newly set cwd ?

Or even
{as above} -doit "do sometihng to the loaded document like maybe save under a new name"

And really, does anyone know what the expectation for those Russian/Japanese language environments are?
See JapaneseEnvironment class>>#inputInterpreterClass & RussianEnvironment class>>#inputInterpreterClass

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
My Go this  amn keyboar  oesn't have any  's.



12