Re: Sun Fortress and Perl 6

0 views
Skip to first unread message

Leopold Toetsch

unread,
Apr 30, 2005, 2:41:52 AM4/30/05
to Autrijus Tang, perl6-i...@perl.org, perl6-l...@perl.org
Autrijus Tang <autr...@autrijus.org> wrote:

> 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

Autrijus Tang

unread,
Apr 30, 2005, 6:35:41 AM4/30/05
to perl6-l...@perl.org, Autrijus Tang, perl6-i...@perl.org
On Sat, Apr 30, 2005 at 08:41:52AM +0200, Leopold Toetsch wrote:
> Anyway Parrots MMD system depends on types. *If* the Perl6 compiler defines
> above array as
>
> cl = subclass "FixedFloatArray", "num_Array_shape_3_3_3"

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/

Aaron Sherman

unread,
Apr 30, 2005, 9:08:34 AM4/30/05
to Perl6 Internals List
On Sat, 2005-04-30 at 08:41 +0200, Leopold Toetsch wrote:

> 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.


Reply all
Reply to author
Forward
0 new messages