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
> 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
> Calling a method:
> object.variable(pararms)
> object."literal name"(params)
Done.
leo
Woohoo!
> 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
> 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
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"?
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 :)
or a class.
leo
Well... only because classes are objects. Or objects are classes.
Possibly both, this OO stuff confuses me sometimes.
> 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
> 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
> So long as you can also do
> .meth_call "foo", PReturnContinuation
This is implemented already.
leo