"Luke Palmer" <[EMAIL PROTECTED]> wrote
> Well, the IO-objects are iterators, and you use <$iter> to iterate.  It
> makes sense that <> would iterate over $*ARGV by default.

When I read this, I instinctively thought to myself: "why does this need to
be global?". And that thought progressed to: "what is the signature of a
main program?"

When you start a perl program, you don't need a "main" function, but the
program is a lexical scope from which you return. its just the "sub"
declaration that is implicit:

  sub main::_([EMAIL PROTECTED]) returns int {...}

or some such thing. Is this really the best signature we could use? Given
that we want a ref to the array to be the default topic, perhaps the
signature is:

  class main is program {
    has @.ARGV is rw;
    has %.ENV is rw;
    method _() returns int { ... }
  }

We could then paste any number of program attributes into that class: %.ENV,
$.STDIN, $.STDOUT, etc. Thing like $*IN would just be aliases to those
attributes: @*ARGV := .ARGV; etc.

If I stretch my imagination a little, I could even see user-code creating
other instances of program you use in place of functions like system and
exec.

  sub qw(Str $exe) { program.new( $exe ) as string }

OK, maybe that's not quite what you'd want, but I you get the picture (I
hope).


Dave.


Reply via email to