Rod Adams wrote:
It used to be

   &foo<Array,Int>
   &foo<Hash,Int>

And has become

  &foo:(Array,Int)
  &foo:(Hash,Int)

The return type arrow --> inside the :() type spec is not
yet approved by @Larry.


In my mind, the more interesting question is what does &foo without the <> specifiers return when foo is multi? I see the following three options:

1) undef/error, since there's no single sub called foo, and multi's need a postfix <>.

This applies only if you want to by-pass actual dispatch by
selecting a sub yourself. Otherwise &foo is an instance of the
class/type MultiMethod which is a subtype of Sub and Method,
which in turn are subtypes of Code.


2) the name 'foo', and then performs in effect call by name when deferenced, using the dereferencing scope to determine which flavors of foo are available at this time, and dispatching accordingly.

I'm unsure how much the Perl6 semantics depend on name lookup
when no explicit symbolic expression ::('foo') is used. But that
aside I think the type is enough information to handle a value.
So &foo is typed &foo:(MultiMethod) or &foo:(Ref of MultiMethod).
This latter thing is another open question on my end: the referential
semantics. E.g. are *all* plain sigil expressions :(Ref of ...) and
need an implicit or explicit dereferencer?


3) a dispatch table of all the foo's currently in scope at the time the reference is made.

Yes, that's it. But note that it's not a passive table that the caller
needs to handle correctly. MMD is about basing the decision which
implementation of a signature to call on the runtime types in the
argument list. Without multi this degenerates to a mere type compatibility
check for subs.

A direct extension of the above is that the type system might be able
to dynamically instanciate parametric types to fill 'gaps' dynamically.
Something like 'compilation on demand' if that is the only way to actually
instanciate a template---but I'm not sure if Perl6's parametric types are
actually called templates.


I hope that helps.
--
TSa (Thomas Sandlaß)

Reply via email to