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

Methods and IMCC

4 views
Skip to first unread message

Dan Sugalski

unread,
Mar 10, 2004, 12:07:02 PM3/10/04
to perl6-i...@perl.org
Time to nail down some method syntax for IMCC. So, what I'd like (and
this is open to discussion) is:

Calling a method:

object.variable(pararms)

object."literal name"(params)

that is, if the method is referenced with a string register or .local
you use the first form and just name the register or local. On the
other hand, making a method call with an actual literal string you
put the method in quotes.

Method declarations:

.pcc_sub foo prototyped, method
.param pmc foo
.param pmc bar

.end

That is, you add a method on the end of the sub declaration line. If
you do so, the local self refers to the object pmc register. (I am OK
with unconditionally doing this, in which case we should define some
other guaranteed aliases)
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk

Leopold Toetsch

unread,
Mar 10, 2004, 1:06:55 PM3/10/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> Time to nail down some method syntax for IMCC. So, what I'd like (and
> this is open to discussion) is:

> Calling a method:

> object.variable(pararms)

Ok.

> object."literal name"(params)

A currently already implemented variant is:

object.label(params)

where label is an unquoted string. I'll do the other two variants
tomorrow, if they aren't done - seems simple now:)

> Method declarations:

> .pcc_sub foo prototyped, method
> .param pmc foo
> .param pmc bar

> .end

> That is, you add a method on the end of the sub declaration line. If
> you do so, the local self refers to the object pmc register. (I am OK
> with unconditionally doing this, in which case we should define some
> other guaranteed aliases)

alternative syntax:

.self me # declare PMC P2 as var me

so

.pcc_sub foo prototyped, method

is

.pcc_sub foo prototyped
...
.self self

which is actually

.local pmc self
self := P2

leo

Leopold Toetsch

unread,
Mar 11, 2004, 8:15:23 AM3/11/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> Calling a method:

> object.variable(pararms)

> object."literal name"(params)

Done.

leo

Dan Sugalski

unread,
Mar 11, 2004, 8:42:48 AM3/11/04
to l...@toetsch.at, perl6-i...@perl.org

Woohoo!

Leopold Toetsch

unread,
Mar 11, 2004, 9:01:26 AM3/11/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> Method declarations:

> .pcc_sub foo prototyped, method
> .param pmc foo
> .param pmc bar

> .end

> That is, you add a method on the end of the sub declaration line. If
> you do so, the local self refers to the object pmc register.

Done.

.namespace [ "Foo" ]
.sub _meth method
print "in meth\n"
isa $I0, self, "Foo"
...

*If* a sub is declared as C<method>, C<self> is a valid identifier
refering to C<P2>.

leo

Leopold Toetsch

unread,
Mar 12, 2004, 3:49:39 AM3/12/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski wrote:

> Calling a method:
>
> object.variable(pararms)

Do we need the more explicit pcc_call syntax too:

.pcc_begin
.arg x
.meth_call PObj, ("meth" | PMeth ) [, PReturnContinuation ]
.result r
.pcc_end

leo

Dan Sugalski

unread,
Mar 12, 2004, 10:13:06 AM3/12/04
to Leopold Toetsch, perl6-i...@perl.org

Sure. Or we could make it:

.pcc_begin
.arg x
.object y
.meth_call "foo"
.result r
.pcc_end

to make things simpler.

Steve Fink

unread,
Mar 12, 2004, 12:57:21 PM3/12/04
to Dan Sugalski, Leopold Toetsch, perl6-i...@perl.org
On Mar-12, Dan Sugalski wrote:
> At 9:49 AM +0100 3/12/04, Leopold Toetsch wrote:
> >Dan Sugalski wrote:
> >
> >>Calling a method:
> >>
> >> object.variable(pararms)
> >
> >Do we need the more explicit pcc_call syntax too:
> >
> > .pcc_begin
> > .arg x
> > .meth_call PObj, ("meth" | PMeth ) [, PReturnContinuation ]
> > .result r
> > .pcc_end
>
> Sure. Or we could make it:
>
> .pcc_begin
> .arg x
> .object y
> .meth_call "foo"
> .result r
> .pcc_end
>
> to make things simpler.

I vote yes -- until we add AST input to imcc, making the args and
invocant be line-oriented makes code generation easier for the Perl6
compiler, at least. (Although I might do it the 1st way anyway, just
because I spend so much time staring at generated code.)

But I had to stare at the ".object" for a second before I realized you
weren't just giving the type of another arg -- would it be better to
use ".invocant"?

Dan Sugalski

unread,
Mar 12, 2004, 12:59:41 PM3/12/04
to Steve Fink, Leopold Toetsch, perl6-i...@perl.org

I don't care either way. Invocant isn't bad as you can do this with
non-object things, so object's not quite right. (Though arguably
anything you make a method call on really is an object :)

Leopold Toetsch

unread,
Mar 12, 2004, 2:34:29 PM3/12/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:
> ... (Though arguably

> anything you make a method call on really is an object :)

or a class.

leo

Dan Sugalski

unread,
Mar 12, 2004, 3:08:52 PM3/12/04
to l...@toetsch.at, perl6-i...@perl.org

Well... only because classes are objects. Or objects are classes.
Possibly both, this OO stuff confuses me sometimes.

Leopold Toetsch

unread,
Mar 13, 2004, 5:31:04 AM3/13/04
to Dan Sugalski, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> wrote:

> Sure. Or we could make it:

> .pcc_begin
> .arg x
> .object y
> .meth_call "foo"
> .result r
> .pcc_end

Done. modulo s/\.object/.invocant/

leo

Piers Cawley

unread,
Mar 16, 2004, 8:11:15 AM3/16/04
to Dan Sugalski, Leopold Toetsch, perl6-i...@perl.org
Dan Sugalski <d...@sidhe.org> writes:

> At 9:49 AM +0100 3/12/04, Leopold Toetsch wrote:
>>Dan Sugalski wrote:
>>
>>>Calling a method:
>>>
>>> object.variable(pararms)
>>
>>Do we need the more explicit pcc_call syntax too:
>>
>> .pcc_begin
>> .arg x
>> .meth_call PObj, ("meth" | PMeth ) [, PReturnContinuation ]
>> .result r
>> .pcc_end
>
> Sure. Or we could make it:
>
> .pcc_begin
> .arg x
> .object y
> .meth_call "foo"
> .result r
> .pcc_end
>
> to make things simpler.

So long as you can also do

.meth_call "foo", PReturnContinuation

Leopold Toetsch

unread,
Mar 16, 2004, 9:18:14 AM3/16/04
to Piers Cawley, perl6-i...@perl.org
Piers Cawley <pdca...@bofh.org.uk> wrote:

> So long as you can also do

> .meth_call "foo", PReturnContinuation

This is implemented already.

leo

0 new messages