develooper Front page | perl.perl6.language | Postings from April 2003

S6: Named parameters are always optional?

Thread Next
From:
John Siracusa
Date:
April 11, 2003 16:48
Subject:
S6: Named parameters are always optional?
Message ID:
BABCC095.67599%siracusa@mindspring.com
I forget if this was covered earlier, but what is the reason for this?  I
can easily imagine wanting to create subroutines that only accept named
parameters, some or all of which are required.  How would this be done in
Perl 6?

Yes, I guess all the parameters could be declared as positional, and then I
could scold users in the documentation to only use named parameters when
calling these subroutines, but that seems silly--and dangerous, since,
inevitably, some users won't listen and will use positional parameters
(after looking at the source to discover the correct order, or whatever).
So I'm stuck maintaining an argument order for what are (as far as I'm
concerned) not positional parameters.

I guess I could also die() if I'm missing a named parameter, but that seems
so Perl-5-ish (i.e. "more work")

So...why can't I have required named parameters?  If it is due to vagaries
of the parameter definition syntax and it's funny little "zones", then I say
change the syntax instead of disallowing required named parameters :)

-John


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About