On Mon, Mar 07, 2005 at 08:58:44PM -0800, David Storrs wrote:
: Ok, rewrite; is THIS legal?:
: 
:       sub foo( Int [EMAIL PROTECTED] is shape(3) ) { ... }
:       foo(1, 2, undef);

Yes, since Int can represent undef.

: The sense I'm trying to convey is:
: 
:     "Here is my sub.  It takes three ints."
: 
:     "Here is me calling the sub.  I am giving you only two ints and
:     explicitly telling you [by explicitly passing undef] that I meant
:     to do that so just take it and be quiet."
: 
: To put it another way...in perl5, a sub that was prototyped to take 
: three scalar args will throw an error when you pass only two but will
: accept it if you pass two plus an explicit undef.  On the other hand,
: if it was prototyped to take an array there is no way to tell the
: difference between an explicitly-passed undef and a too-short arg
: list.  How will P6 handle these two scenarios?

Could use "exists", maybe.  Though for an array with shape(3)
it's possible that exists(@a[2]) is always true regardless of the
bound value.  On the other hand, binding an array that is too short
is going to be a type mismatch, so you probably can't get into the
situation of a shaped array being too short to begin with.  It'll
either fail immediately in the case of a normal sub, or it'll
go off looking for something else to MMD to that doesn't violate
any type constraints, and fail if it doesn't fine one.

Larry

Reply via email to