On 8/26/06, Audrey Tang <[EMAIL PROTECTED]> wrote:
Mostly, it's that func('&x' => 1) requires a bit too much typing, and also makes it hard for func() to change its signature later on to accept things other than Code.
Allow me to make an immodest proposal. Have named parameter passing look like this: ':' . param name (including sigil) . ( '(' . value . ' )' x (0|1)). So func('&x' => 1) would become func(:&x(1)). The colon would consistently have the effect of "preventing evaluation" of the key (as it currently does by having :foo(1) not call foo()). The call foo(:$bar($baz)) would assign the value of the variable $baz to the named parameter '$bar" and would have nothing to do with the caller's $bar variable, although it could default to that so that foo(:$bar) would still have its current semantics. Perhaps the sigil could be optional when there is only one parameter matching the rest of the name, or else the callee's signature would be able to specify that the sigil is optional. I would then make key => value always be a Pair value. For module writers to support perl5 calling semantics, I'd prefer a mechanism for asking for that explicitly in the signature rather than jumping through hoops to support it by default. Perhaps there could be a rule that, in the absence of a slurpy hash declaration, any trailing Pairs are scanned for matches to named parameters? -- Mark J. Reed <[EMAIL PROTECTED]>