On Thu, Mar 03, 2005 at 10:25:30AM -0500, Abhijit Mahabal wrote: : Another edge case: is it legal to have an optional Pair in the : signature? That is: : sub foo($x, Pair ?$y, +$z){...} : : If yes, what does this parse as: : foo(10, z => 5);
It ends up equivalent to foo(10, y => (z => 5), z => undef); : If z => 5 is bound to $y, then $y is almost mandatory. ('almost' because : we can still say foo(10); ). (and then can we also say foo(10, z => 5, z : => 6)? :) That at least has the feature that it can be used to write : bizarre code like C< sing :e:i:e:i:o > ) : : If it is bound to $z instead, how do we bind anything to $y : positionally? Might as well change that to +$y. Er, by not naming it "z" maybe? But the situation doesn't arise. Named binding only takes over after positional binding gives up. So there's really not much ambiguity--the first pair is always bound to $y, regardless of its name, and once that pair is slurped into the second argument, it's no longer available for named binding, and $z stays unbound. : It seems to me that an optional Pair is a catastrophe waiting to happen, : and maybe it should just be illegal (or produce a warning at least) One can say catastrophic things in English too, and a few of those are illegal, while a larger subset gets you a warning from your mother--but by and large we don't outlaw stupid utterances, because sometimes collections of stupid utterances can be rather clever. If my writings are ever published posthumously, they should probably be called "A Collection of Stupid Utterances", or some such... :-) : Sorry if this has been gone over before... Nope, hasn't--unless you count publishing the binding semantics as pseudocode in A6 that implies the positional parameters always take precedence over named. But we haven't made it terribly clear. Thanks. Larry