On Fri, 4 Aug 2000, Simon Cozens wrote:

> On Thu, Aug 03, 2000 at 09:39:30AM -1000, Tim Jenness wrote:
> > Reading through the docs for perl prototypes I see that there is a
> > reference to "named parameters" being a possibility in future versions of
> > perl.
> > 
> > Does anyone have a more concrete example of what was intended there? 
> 
> sub marine ($sailor, $captain) {
>     $captain->say("One ping only");
> }
> 

Fair enough. If we were going to do it I would like to see it extend to:

 sub test ( $x, @y:[N], %z, $fh:isa(IO::Handle) ) {

 }

or somesuch, so that we can automatically dereference array and hash refs
and make sure that argument 4, for example, is a IO::Handle object, @y has
to have N elements etc [my syntax is not meant to be all that well thought
out just at the moment.]

I find that I spend quite a lot of code checking that arguments are in the
correct class, that I have array refs and things so anything that would
save typing is a good thing IMHO.

Of course, type checking can be done as 

  use Type::Checking qw/ checkargs /;

  sub test {
    checkargs( "$x, @y:[N], %z", @_);
        or die "Incorrect args";

  }

[where Type::Checking is a mythical module] without extending the language 
at all...


-- 
Tim Jenness
JCMT software engineer/Support scientist
http://www.jach.hawaii.edu/~timj


Reply via email to