> my sub get_book () of Hash of Array of Recipe {...}
> my num @nums = Array of num.new(:shape(3;3;3));
> Does Parrot's MMD carry this type information natively?
Neither of above. But:
multi sub foo(Int $a, Num $b) { ... }
aka
.sub foo @MULTI(Int, Num)
- creates a MultiSub PMC stored in the current namespace as "foo"
- stores the sub itself as "foo_@Int_@Num" and
- attaches that Sub PMC to the MultiSub
> ..., and Ponie can then
> reuse the same name-mangling to call into Perl 6 subroutines.
Well, I presume that this could cover just the static case, which with
the absence of types in Perl5/Ponie, would make it impossible to call
multisubs.
Anyway Parrots MMD system depends on types. *If* the Perl6 compiler defines
above array as
cl = subclass "FixedFloatArray", "num_Array_shape_3_3_3"
then this kind of array would be a distinct type. The other possiblity
is: we have one Multi_shaped_FloatArray, which takes an initializer with
the dimensions (see e.g. classes/multiarray.pmc) then all these shaped
num arrays would be one type, dispatching to the same routines.
> Thanks,
> /Autrijus/
leo
Yes, that is what I am planning to emit for hierarchical and other
subtyped signatures. We also need to generate those for the
user-defined "subtype" things in Perl 6.
> then this kind of array would be a distinct type. The other possiblity
> is: we have one Multi_shaped_FloatArray, which takes an initializer with
> the dimensions (see e.g. classes/multiarray.pmc) then all these shaped
> num arrays would be one type, dispatching to the same routines.
Hm, I have no clue whether we can MMD based on shape of arrays.
Anyone has ideas about that?
Thanks,
/Autrijus/
> Well, I presume that this could cover just the static case, which with
> the absence of types in Perl5/Ponie, would make it impossible to call
> multisubs.
I suppose then, that languages like Ponie or Python will end up needing
builtin operators that expose the raw multi calling conventions of
Parrot. e.g.:
parrot_invoke 'foo_@Int_@Num', $x, $y
That could then be hidden in a module if you didn't want to expose it to
end-users.
For most multi subs in P6 or other typed languages with multi-type
overloading, I suspect there will be a reasonable default signature that
could be exported to P5, et al. without too much loss of functionality.