On Tue, Apr 20, 2004 at 03:53:31PM -0400, Aaron Sherman wrote:
: In specific, here is a proposal for execution:
: 
:       multi run(string $command) returns(Process) {...} # Funky shell default
:       multi run(Process $process) returns(Process) {...} # Relies on $process.cmdline

Eh?  What does it mean to run a process that presumably is already running?

:       multi run(Program $program, IO::Mode $mode=undef) returns(Process) {...}
:       
: which gives us our process control, all nicely bottled up:
: 
:       my Process $p = run("find / -name null");
:       say "Spawned find $($p.getpid)";
:       $p.kill('TERM');
: 
: But if you don't want that, you can always:
: 
:       run("find / -name null").wait;
: 
: which might have an alias called "system".

I'm trying to avoid "system" actually, since it's backwards on its
booleanness in Perl 5, and it would be confusing to just swap it.

: And if you provide mode:
: 
:       my Process $p = run(program=>"find / -name null", mode=>"r");
: 
: Then you actually get back a:
: 
:       class ExecPipe is Process does IO::Handle {...}
: 
: which lets you do:
: 
:       say "Found null at: $p.getline";
: 
: and which could have a wrapper:
: 
:       $x = readpipe("pwd");
: 
: ahhh... simple.

Er, yeah...

: open2, open3, exec and all manner of other strange things should be
: simple aliases for complex run invocations.

The complicated interface should have a longer name name "run".  I was
thinking run was the new name of "system", and possibly is context sensitive
on its I/O redirection.

: The reason for making Program an object? Why for this:
: 
:       run(Program(path=>"find",name=>"finding null",args=>[<</ -name 
null>>],exec=>true));
: 
: which has the alias "exec".

I kinda cringe to see exec=>true when we just defined :exec to mean that...

: Making this as magical as Perl 5 system would be difficult, though, and
: I'm not sure you need to preserve that particular way of doing things.

Not sure which magic you're referring to.  system() is pretty stupid,
other than a little optimization to bypass the shell when it can.

: I leave the definition of Program up to the imagination of the reader.

Oh, oh...

: Incidentally, if Process is a standard class, and happens to do:
: 
:       class Process {
:               ...
:               method prefix:~() { return ~($.getpid) }
:               method prefix:+() { return $.getpid }
:               ...
:       }
: 
: Then $$ is just a Process object, but behaves exactly as you always
: expected it to.
: 
:       $$.kill("ABRT")
: 
: then does what you might expect, as does:
: 
:       say $$.cmdline;

Okay, but there is no $$ anymore.  It'd be $*PID or $*PROC or some such.

Larry

Reply via email to