On 3/31/07, Allison Randal <[EMAIL PROTECTED]> wrote:
Alek Storm wrote:
>>
>> $P0 = get_hll_namespace
>> $P1 = $P0.find_class("HLLClass")
>> $P2 = $P1.new()
>
>
> Will new() be a vtable method or PCCMETHOD in a Class PMC?  That's the
only
> way I can see this syntax not conflicting with normal method-calling
> syntax.

new() is a class method, an ordinary method on the class object. So, in
this code:

$P1 = get_class "Dog"
$P2 = $P1.new()
$P2.foobar()

new() is a method called on the class object, and foobar() is a method
called on the instance of the class object. The two don't conflict
because they're called on different objects.


It sounds like you're getting confused about what a PCCMETHOD is. It's a
method defined in C code that can be called using the full Parrot
calling conventions. That is, it's an ordinary method.

Allison


Apparently I came off as not fully knowing what I was talking about.
I was expecting new() to be a vtable method, since that is the only
way we can guarantee that whatever PMC comes out of find_class
implements new().  We don't want code to crash because somebody stuck
a non-class PMC into Parrot as a class.  In addition, since vtable
methods are not PCCMETHODs, new() would not be directly callable from
PIR.  Hence my confusion.

So, I think we should keep the "new" opcode and make new() a vtable
method, which is called from inside the "new" opcode.  This allows
PMCs to create class instances their own way, which is more than
necessary given that ParrotClass, the default implementation, doesn't
work for the semantics of all languages.  According to PDD15,
"[Isolation from implementation details] also allows for multiple
concurrent interoperable object systems. The major thrust is for
transparent use of objects, though most class activity (including
creation of subclasses and modifications of existing classes) should
be transparent as well."

So, whaddya think?

--
Alek Storm

Reply via email to