Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[COMMIT] perl6 sub calling

7 views
Skip to first unread message

Steve Fink

unread,
Oct 13, 2003, 1:18:44 PM10/13/03
to perl6-i...@perl.org
For those of you not on the CVS list, I just committed a rather large
change to the perl6 compiler that implements a subset of the A6
subroutine signature rules. My implementation is rather ad-hoc, but it
is a decent representation of my slowly evolving understanding of how
this stuff's supposed to work. Eventually, I'd like to rewrite it to
be more encapsulated, and make it plug into the parser better. Ooh,
and it needs some runtime context stuff, but I don't think that really
exists anywhere in perl6 right now.

Even better, I'd love to see someone else rewrite it properly.

See languages/perl6/t/compiler/call.t for several examples of usage.
Briefly, it handles things like:

sub f ($a, $b) { ... }
sub g ($a, +$b) { ... }
sub h ($a, *@b) { ... }

f(1,2);
f(a, b => 2);
g(a => 1, b => 2);
h(1, 2, 3, 4);
h(1, 2, *@x, 40);

It pretends to handle optional parameters, but if you don't pass in a
value to an optional parameter, it reuses whatever happened to be
lying around in that register, and there's no way of telling whether
the caller specified a value or not.

I doubt anyone will actually use any of this for a while, so unless I
get change requests I'm planning on leaving this in its current
half-baked state for now, and going back to using it for a regular
expression engine, which is why I went down this rabbit hole in the
first place.

0 new messages