On Wednesday, March 19, 2003, at 09:58 AM, Larry Wall wrote:
: sub foo($x, [EMAIL PROTECTED], +$k) {...} # (2) OK

Fine, you can set @a using positional notation, like push(), in
addition to the notations available to (1).  But if you set "k =>",
it has to be before the list, unless you pass the list explicitly as
a "*@" named parameter.  With the exception of [EMAIL PROTECTED] at the front as
in (2), non-positional parameters don't pay any attention to their
order of declaration.

It's the "with the exception of [EMAIL PROTECTED] at the front" part that worries me quite a bit. I'd be a lot happier with having the rule be "non-positional parameters must come after positional parameters, but before any variadic elements".


I think newbies are going to unquestionably try and put the parameters in the same order as they expect to see the eventual arguments, and be durn confused it doesn't work -- I know I would. Especially because:

   sub foo($x, +$k, *%h) {...}     # (3)
   sub foo($x, *%h, +$k) {...}     # (4)

_are_ synonymous, but

   sub foo($x, +$k, [EMAIL PROTECTED]) {...}     # (1)
   sub foo($x, [EMAIL PROTECTED], +$k) {...}     # (2)

are quite definitely not.

Dunno. I'm just one datapoint, but I strongly see the difference between (1) and (2) as being a *huge* newbie trap. And it doesn't seem like you ever gain anything by specifying (1) -- I don't know why you would ever purposefully _want_ to do that, instead of (2). So I would still strongly urge that (1) and (2) be synonyms.

MikeL



Reply via email to