Fwd: how to get arg and print on the output

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

Fwd: how to get arg and print on the output

stéphane ducasse-2
Hi guys


>>> What I do not know is how can I print on stdoutput?
>>> Once roel implemented a primitive for that, is it the only way?
>>> It would be get per default to have that.
>>>
>>
>> On recent  versions of VW:
>>   Stdout nextPutAll: 'Helo World'; flush


Can we get the same in squeak?

Stef

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: how to get arg and print on the output

Andreas.Raab
stéphane ducasse wrote:
>>> On recent  versions of VW:
>>>   Stdout nextPutAll: 'Helo World'; flush
>
>
> Can we get the same in squeak?

I'll eat my hat if works on Windows - a GUI program has no stdout so
that such an invokation (unless done from a special "command line VM")
simply cannot have any useful effect.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: Fwd: how to get arg and print on the output

David T. Lewis
On Mon, Aug 14, 2006 at 04:53:48PM -0700, Andreas Raab wrote:

> st?phane ducasse wrote:
> >>>On recent  versions of VW:
> >>>  Stdout nextPutAll: 'Helo World'; flush
> >
> >
> >Can we get the same in squeak?
>
> I'll eat my hat if works on Windows - a GUI program has no stdout so
> that such an invokation (unless done from a special "command line VM")
> simply cannot have any useful effect.

I don't know about VW, but it works fine on Windows with Squeak(*).
Standard output goes to the console, so you can open a console and
write to standard output. The console conveniently displays itself
in a separate window, and behaves more or less as you might expect.
The console window can be opened and closed as needed.

Dave

(*) Actually, it does not work any more due the the recent security
enhancements to the Windows FilePlugin support code. But it used to
work, and it did have a useful effect. No special VM required, just
the OSPP plugin for Windows.


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: how to get arg and print on the output

Andreas.Raab
David T. Lewis wrote:

> On Mon, Aug 14, 2006 at 04:53:48PM -0700, Andreas Raab wrote:
>> st?phane ducasse wrote:
>>>>> On recent  versions of VW:
>>>>>  Stdout nextPutAll: 'Helo World'; flush
>>>
>>> Can we get the same in squeak?
>> I'll eat my hat if works on Windows - a GUI program has no stdout so
>> that such an invokation (unless done from a special "command line VM")
>> simply cannot have any useful effect.
>
> I don't know about VW, but it works fine on Windows with Squeak(*).
> Standard output goes to the console, so you can open a console and
> write to standard output. The console conveniently displays itself
> in a separate window, and behaves more or less as you might expect.
> The console window can be opened and closed as needed.

But what would be the point of that? The main use of stdout and stdin
lies in the ability of doing I/O redirection. Creating new consoles
(which is admittedly trivial) is not helping with that.

Cheers,
   - Andreas

Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

stéphane ducasse-2
Andreas

I'm fed up to see people coming to squeak and after saying that they  
use Ruby for scripting (writing small program
that perform string manipulations and output some results). We have  
good regexp packages. For these people having a
result printed in a console is important and I would like to have the  
same possibility in Squeak.  They do not like/understand
the idea of an IDE but want to see the results at their prompt.

So just having a printout is the first step but an important one. I  
think that Ruby success is also because they are not trapped in an image
(which they may discover soon as a program cache and everybody will  
find that cool). Still good C and system interaction
is still something that looks complex to me (but I never tried).

Stef


>>>> Can we get the same in squeak?
>>> I'll eat my hat if works on Windows - a GUI program has no stdout  
>>> so that such an invokation (unless done from a special "command  
>>> line VM") simply cannot have any useful effect.
>> I don't know about VW, but it works fine on Windows with Squeak(*).
>> Standard output goes to the console, so you can open a console and
>> write to standard output. The console conveniently displays itself
>> in a separate window, and behaves more or less as you might expect.
>> The console window can be opened and closed as needed.
>
> But what would be the point of that? The main use of stdout and  
> stdin lies in the ability of doing I/O redirection. Creating new  
> consoles (which is admittedly trivial) is not helping with that.
>
> Cheers,
>   - Andreas
>


Reply | Threaded
Open this post in threaded view
|

Re: Fwd: how to get arg and print on the output

David T. Lewis
In reply to this post by Andreas.Raab
On Mon, Aug 14, 2006 at 10:59:16PM -0700, Andreas Raab wrote:

> David T. Lewis wrote:
> >I don't know about VW, but it works fine on Windows with Squeak(*).
> >Standard output goes to the console, so you can open a console and
> >write to standard output. The console conveniently displays itself
> >in a separate window, and behaves more or less as you might expect.
> >The console window can be opened and closed as needed.
>
> But what would be the point of that? The main use of stdout and stdin
> lies in the ability of doing I/O redirection. Creating new consoles
> (which is admittedly trivial) is not helping with that.

It makes a nice alternative to the Transcript for debugging multiple
processes. Otherwise I have not found any use for it.

Dave
 

Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

timrowledge
In reply to this post by Andreas.Raab

On 14-Aug-06, at 10:59 PM, Andreas Raab wrote:
[snip]

>>> I'll eat my hat if works on Windows - a GUI program has no stdout  
>>> so that such an invokation (unless done from a special "command  
>>> line VM") simply cannot have any useful effect.
>> I don't know about VW, but it works fine on Windows with Squeak(*).
>> Standard output goes to the console, so you can open a console and
>> write to standard output. The console conveniently displays itself
>> in a separate window, and behaves more or less as you might expect.
>> The console window can be opened and closed as needed.
>
> But what would be the point of that? The main use of stdout and  
> stdin lies in the ability of doing I/O redirection. Creating new  
> consoles (which is admittedly trivial) is not helping with that.
Well since the original question is how to get printing of some sort  
to a stdout-like output I think Dave's point is probably sufficient.  
Time to get a hat shaped cake from the bakery..... pictures for proof  
please.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Unprecedented performance: Nothing ever ran this slow before.



Reply | Threaded
Open this post in threaded view
|

Re: Re: how to get arg and print on the output

Damien Pollet
In reply to this post by stéphane ducasse-2
On 8/15/06, stéphane ducasse <[hidden email]> wrote:
> I'm fed up to see people coming to squeak and after saying that they
> use Ruby for scripting (writing small program
> that perform string manipulations and output some results). We have
> good regexp packages. For these people having a
> result printed in a console is important and I would like to have the
> same possibility in Squeak.  They do not like/understand
> the idea of an IDE but want to see the results at their prompt.

To be more precise, Smalltalk gives the impression (at least that's
what it gives to me as a beginner) of being an autistic system,
trapped inside its image. A squeak image looks more like yet another
OS installation to administrate than a tool that integrates in an
existing OS.

Mind you I really like Smalltalk because it's so much more clean, but
right now I'll still use Ruby when I have to write a 20-line script
just to automate simple stuff. It's simply faster to fire up emacs and
edit a file than setup a new image, load/create a monticello package,
etc

It's not trivial to pipe stuff to/from other shell commands, to give
arguments from the command line, etc. Basically it's not
straightforward to use it as a replacement for bash or ruby. So for
most linux guys I know it seems useless because they can't integrate
it with their existing tools and habits.

--
 Damien Pollet
 type less, do more


Reply | Threaded
Open this post in threaded view
|

Re: Re: Re: how to get arg and print on the output

Damien Pollet
On 8/21/06, Damien Pollet <[hidden email]> wrote:
> It's not trivial to pipe stuff to/from other shell commands, to give
> arguments from the command line, etc.

PS. that's for those who primary live in a shell window :-)

As one also living in Mac OS and Gnome, I'd really prefer a native
Squeak UI using resp. Cocoa and GTK2 than the current self-contained
Morphic window.

--
 Damien Pollet
 type less, do more

Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

Bert Freudenberg-3
In reply to this post by Damien Pollet
Damien Pollet schrieb:

> On 8/15/06, stéphane ducasse <[hidden email]> wrote:
>> I'm fed up to see people coming to squeak and after saying that they
>> use Ruby for scripting (writing small program
>> that perform string manipulations and output some results). We have
>> good regexp packages. For these people having a
>> result printed in a console is important and I would like to have the
>> same possibility in Squeak.  They do not like/understand
>> the idea of an IDE but want to see the results at their prompt.
>
> To be more precise, Smalltalk gives the impression (at least that's
> what it gives to me as a beginner) of being an autistic system,
> trapped inside its image. A squeak image looks more like yet another
> OS installation to administrate than a tool that integrates in an
> existing OS.

Well, because it is. At least a headed image.

> Mind you I really like Smalltalk because it's so much more clean, but
> right now I'll still use Ruby when I have to write a 20-line script
> just to automate simple stuff. It's simply faster to fire up emacs and
> edit a file than setup a new image, load/create a monticello package,
> etc
>
> It's not trivial to pipe stuff to/from other shell commands, to give
> arguments from the command line, etc. Basically it's not
> straightforward to use it as a replacement for bash or ruby. So for
> most linux guys I know it seems useless because they can't integrate
> it with their existing tools and habits.

Right - so this really only applies to headless command line use. So why
not create a special squeak shell for them?

You could create a stripped image with OSProcess preloaded, write a
small shell script or launcher program (say, "squeash") that runs a
headless VM with the image, et voilà, Squeak for scripting.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

stéphane ducasse-2
>
> Right - so this really only applies to headless command line use.  
> So why not create a special squeak shell for them?
>
> You could create a stripped image with OSProcess preloaded, write a  
> small shell script or launcher program (say, "squeash") that runs a  
> headless VM with the image, et voilà, Squeak for scripting.

Exact! And with a syntax for writing method and class without !! and !
I will give a try at that.


Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

florent trolat
stéphane ducasse a écrit :

>>
>> Right - so this really only applies to headless command line use. So
>> why not create a special squeak shell for them?
>>
>> You could create a stripped image with OSProcess preloaded, write a
>> small shell script or launcher program (say, "squeash") that runs a
>> headless VM with the image, et voilà, Squeak for scripting.
>
> Exact! And with a syntax for writing method and class without !! and !
> I will give a try at that.

(hi,) an example of syntax?
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

Bert Freudenberg-3
florent trolat schrieb:

> stéphane ducasse a écrit :
>>>
>>> Right - so this really only applies to headless command line use. So
>>> why not create a special squeak shell for them?
>>>
>>> You could create a stripped image with OSProcess preloaded, write a
>>> small shell script or launcher program (say, "squeash") that runs a
>>> headless VM with the image, et voilà, Squeak for scripting.
>>
>> Exact! And with a syntax for writing method and class without !! and !
>> I will give a try at that.
>
> (hi,) an example of syntax?

I like Ian's:

        http://piumarta.com/pepsi/pepsi.html

There are others, like

        http://www.double.co.nz/smallscript/byexample.htm

- Bert -


Reply | Threaded
Open this post in threaded view
|

Squeak scripting syntax (was: Re: how to get arg and print on the output)

Andreas.Raab
Couple of years back I used something quite similar to Ian's version -
the main difference was that instead of prototypes it used classes so it
would look like this:

Object subclass: #Point definition: #[
     | x y |
     magnitude [
         ^((x * x) + (y * y)) sqrt
     ]
]

(I still have an ~400k image based on this stuff ;-) The trick in the
above is that I redefined #[] to mean a "token array" that would be
processed as part of the #subclass:definition: message so it retained
the expression nature of class definitions. It's kind of cool but also
overkill - these days I'd go straight for human readable syntax instead
of fancy parser tricks ;-)

Cheers,
   - Andreas


Bert Freudenberg wrote:

> florent trolat schrieb:
>> stéphane ducasse a écrit :
>>>>
>>>> Right - so this really only applies to headless command line use. So
>>>> why not create a special squeak shell for them?
>>>>
>>>> You could create a stripped image with OSProcess preloaded, write a
>>>> small shell script or launcher program (say, "squeash") that runs a
>>>> headless VM with the image, et voilà, Squeak for scripting.
>>>
>>> Exact! And with a syntax for writing method and class without !! and !
>>> I will give a try at that.
>>
>> (hi,) an example of syntax?
>
> I like Ian's:
>
>     http://piumarta.com/pepsi/pepsi.html
>
> There are others, like
>
>     http://www.double.co.nz/smallscript/byexample.htm
>
> - Bert -
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

stéphane ducasse-2
In reply to this post by Bert Freudenberg-3
Yeap I like the one of pepsi (in fact I really like the { } for C),  
this is really excellent.
but for Smalltalk I prefer that one that is closer to Smalltalk one.

> KernelPackage
> import: Point.

or
Point from: KernelPackage

>
> Package declare: 'ColoredPointPackage'.
>
> Point < ColoredPpoint
> variables: 'x y' ;
> classvar: 'Foo'
>
> ColoredPoint>>foo: zork
> [  <category: 'foobar'>
>
>> <author: 'sd' date: '24/06/2006'>
>>
> ljkljl
> ^ self
>         ]
>

  ColoredPoint class>> new
        [ ^ self basicNew ]




Reply | Threaded
Open this post in threaded view
|

Re: Squeak scripting syntax (was: Re: how to get arg and print on the output)

Bert Freudenberg-3
In reply to this post by Andreas.Raab
Neat!

If we want to play parser tricks, however, we could get rid of the  
extra brackets by making leading whitespace significant inside of #
[]. Admitted, I like Python for that feature ;-)

Object subclass: #Point definition: #[
     | x y |
     magnitude
         ^((x * x) + (y * y)) sqrt
     + aPoint
         ^(x + aPoint x) @ (y + aPoint y)
].

- Bert -

Am 21.08.2006 um 15:56 schrieb Andreas Raab:

> Couple of years back I used something quite similar to Ian's  
> version - the main difference was that instead of prototypes it  
> used classes so it would look like this:
>
> Object subclass: #Point definition: #[
>     | x y |
>     magnitude [
>         ^((x * x) + (y * y)) sqrt
>     ]
> ]
>
> (I still have an ~400k image based on this stuff ;-) The trick in  
> the above is that I redefined #[] to mean a "token array" that  
> would be processed as part of the #subclass:definition: message so  
> it retained the expression nature of class definitions. It's kind  
> of cool but also overkill - these days I'd go straight for human  
> readable syntax instead of fancy parser tricks ;-)
>
> Cheers,
>   - Andreas
>
>
> Bert Freudenberg wrote:
>> florent trolat schrieb:
>>> stéphane ducasse a écrit :
>>>>>
>>>>> Right - so this really only applies to headless command line  
>>>>> use. So why not create a special squeak shell for them?
>>>>>
>>>>> You could create a stripped image with OSProcess preloaded,  
>>>>> write a small shell script or launcher program (say, "squeash")  
>>>>> that runs a headless VM with the image, et voilà, Squeak for  
>>>>> scripting.
>>>>
>>>> Exact! And with a syntax for writing method and class without !!  
>>>> and !
>>>> I will give a try at that.
>>>
>>> (hi,) an example of syntax?
>> I like Ian's:
>>     http://piumarta.com/pepsi/pepsi.html
>> There are others, like
>>     http://www.double.co.nz/smallscript/byexample.htm
>> - Bert -
>



Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

Alejandro F. Reimondo
In reply to this post by stéphane ducasse-2
> > KernelPackage import: Point.
> or
> Point from: KernelPackage

really? or it must be:
    KernelPackage import: #Point
because the object named Point does
 not exist in the context, yet...

If objects KernelPackage and
 Point are already bound, what does
 the #import: mean?

If the meaning of #import: is to
 bind an object to a name in a context,
 I prefer the message to be sent to the
 bounding environment or to the source
 space (KernelPackage) to solve the
 binding action.

best,
Ale



----- Original Message -----
From: "stéphane ducasse" <[hidden email]>
To: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Monday, August 21, 2006 1:25 PM
Subject: Re: how to get arg and print on the output


> Yeap I like the one of pepsi (in fact I really like the { } for C),
> this is really excellent.
> but for Smalltalk I prefer that one that is closer to Smalltalk one.
>
> > KernelPackage
> > import: Point.
>
> or
> Point from: KernelPackage
>
> >
> > Package declare: 'ColoredPointPackage'.
> >
> > Point < ColoredPpoint
> > variables: 'x y' ;
> > classvar: 'Foo'
> >
> > ColoredPoint>>foo: zork
> > [  <category: 'foobar'>
> >
> >> <author: 'sd' date: '24/06/2006'>
> >>
> > ljkljl
> > ^ self
> >         ]
> >
>
>   ColoredPoint class>> new
> [ ^ self basicNew ]
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

stéphane ducasse-2

On 21 août 06, at 19:27, Alejandro F. Reimondo wrote:

>>> KernelPackage import: Point.
>> or
>> Point from: KernelPackage
>
> really? or it must be:
>     KernelPackage import: #Point
> because the object named Point does
>  not exist in the context, yet...

Yes!

> If objects KernelPackage and
>  Point are already bound, what does
>  the #import: mean?

True!!!

> If the meaning of #import: is to
>  bind an object to a name in a context,
>  I prefer the message to be sent to the
>  bounding environment or to the source
>  space (KernelPackage) to solve the
>  binding action.

100% correct

>
> best,
> Ale
>
>
>
> ----- Original Message -----
> From: "stéphane ducasse" <[hidden email]>
> To: "The general-purpose Squeak developers list"
> <[hidden email]>
> Sent: Monday, August 21, 2006 1:25 PM
> Subject: Re: how to get arg and print on the output
>
>
>> Yeap I like the one of pepsi (in fact I really like the { } for C),
>> this is really excellent.
>> but for Smalltalk I prefer that one that is closer to Smalltalk one.
>>
>>> KernelPackage
>>> import: Point.
>>
>> or
>> Point from: KernelPackage
>>
>>>
>>> Package declare: 'ColoredPointPackage'.
>>>
>>> Point < ColoredPpoint
>>> variables: 'x y' ;
>>> classvar: 'Foo'
>>>
>>> ColoredPoint>>foo: zork
>>> [  <category: 'foobar'>
>>>
>>>> <author: 'sd' date: '24/06/2006'>
>>>>
>>> ljkljl
>>> ^ self
>>>         ]
>>>
>>
>>   ColoredPoint class>> new
>> [ ^ self basicNew ]
>>
>>
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how to get arg and print on the output

David T. Lewis
In reply to this post by Bert Freudenberg-3
On Mon, Aug 21, 2006 at 03:02:52PM +0200, Bert Freudenberg wrote:
> You could create a stripped image with OSProcess preloaded, write a
> small shell script or launcher program (say, "squeash") that runs a
> headless VM with the image, et voil?, Squeak for scripting.

I actually had a fairly good implementation of this working in Squeak 3.2
that I never got around to cleaning up and releasing. It ran headless, and
you could run an OSProcess CommandShell more or less the same way that
you would use /usr/bin/bash.  I'll see if I can get it cleaned up and
merged back into present-day OSProcess one of these days. Too bad I did
not have Monticello back then ;)

Dave