On Mon, Aug 07, 2000 at 01:51:55PM -0700, Jacob Davies wrote:
> And in fact if you require the prefixes, you're *continually* going
> to be writing code that looks like:
>
> foo( $name : $name, @addresses : @addresses, $email : $email );
>
> because you're often going to name in-scope variables the same thing as
> the parameter names for the sub.
No, you'd write that as:
foo($name,@addresses,$email);
with a proper prototype on foo(). Why would you use the named version
there?
> I prefer:
>
> foo( name : $name, addresses : @addresses, email : $email );
If you're going to allow named parameters as part of your interface,
wouldn't it be better to keep the prefixes to remind the user of the
type of thing that's expected?
I'm half-way to proposing that we just don't have named parameters.
Each time I look at them they show me a Good face and an Evil face.
How's this for a counter proposal? Rather than having named
parameters, we let the user omit parameters that will have a default
value. Thus,
sub foo ($fname = 'Fred', $lname = 'Flintstone', $age = 32) {
...
}
foo(,,33); # Fred, Flintstone, 33
foo(,'Johnston',24); # Fred, Johnston, 24
Isn't that the problem that named parameters solves? Why would you
ever want named parameters rather than a hash?
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]