On May 23, 2009 04:10:49 pm John M. Dlugosz wrote:
> Henry Baragar Henry.Baragar-at-instantiated.ca |Perl 6| wrote:
> > I think that in your "Example 1", that you may be making too making too
> > much of a distinction between "$a" and "@a".  That is:
> >     sub f2(@y) {...}
> > has exactly the same signature as
> >     sub f2($x is Array) {...}
> > In other words, they both take a single argument that must be of type
> > Array. Hence, @y and $x work the same "beneath the surface" and there is
> > no extra level of indirection.
>
> But... $x has an Item container, and @y doesn't !
>
From whence did it get its Item container?

> > Now that we are viewing parameters as providing constraints rather than
> > contexts, we get a different view on your "Example 2".  I made your
> > example
> >
> > more concrete and ran it through rakudo, yielding:
> >     > sub f1 ($x) {say $x.WHAT}; f1(Nil);
> >
> >     Nil()
> >
> >     > sub f2 (@y) {say @y.WHAT; say +...@y}; f2(Nil);
> >
> >     Array()
> >     1
>
> Why doesn't +...@y produce 0, not 1?  It's an empty list.
From rakudo:
        > sub f2 (@y) {say @y[0]}; f2(Nil);
        Nil()

Henry

> And if the argument types are viewed as constraints only, denoting
> whether the call is acceptable but not changing anything about it, and
> f2 is written as way above, the two functions would produce the same
> output.  Clearly they're not.
>
> > See, no problems with f2().
>
> Good.  Thanks.

-- 

Henry Baragar
Instantiated Software
416-907-8454 x42

Reply via email to