On Sat, Mar 26, 2005 at 09:59:10AM -0500, Aaron Sherman wrote:
: On Sat, 2005-03-26 at 00:27 -0800, Larry Wall wrote:
: 
: > $$ is now $*PID.  ($$foo is now unambuous.)
: > 
: > $0 is gone in favor of $*PROGRAM_NAME or some such.
: 
: You know, Java did one thing in this respect that I liked, and managed
: to do it in a way that I couldn't stand. The idea of program as object
: was nice, but they made the programmer manage it, which was really kind
: of silly.

Well, there is a process object, but it actually exists inside the
operating system.  It's a little silly to force people to name their
own process all the time.  I think we can assume that global variables
belong to the current process, sort of on the "you're soaking in it"
principle.

: If you think of the OS-level shell around a Perl interpreter as an
: object, and make perl manage that for you, then this falls out rather
: nicely:
: 
:       $*PID := $*PROC.pid;
:       $*PPID := $*PROC.ppid;
:       $*PROGRAM_NAME := ~$*PROC;
: 
: Perhaps even some often-used data could be shoved in there:
: 
:       $life = time() - $*PROC.start_time;
: 
: In fact, it seems like a good place for any OS-level globals:
: 
:       $*IN := $*PROC.pio_in // $*PROC.stdin;

We can certainly have various objects proxying for various contexts.
It's not clear how those should be broken out though.  To me, an OS
isn't a process, and there's not necessarily going to be a one-to-one
correspondence.

: If we consider $*PROC to be the invocant of the implicit "main", then:
: 
:       say "I am number {.pid}, who is number 1?";
: 
: works just fine in global context. This also gives you a nice simple way
: to drill down into your interpreter / runtime / VM / whatever state:
: 
:       say "I'm {.name} running under {.interp.name}";

That's an interesting idea, the more so now that we're leaning away
from .foo ever assuming the current topic unless it also happens to
be the invocant.  But it probably wouldn't do to have one common name for
the .pid outside of methods and force people to use a different name
inside methods.  Here's where $*PID works much better, because it can
be the same everywhere.

Larry

Reply via email to