Klaas-Jan Stol wrote:

hi,

My question concerns functionality of PMCs and Objects.

while reading the docs about the functionality of classes and objects, I read that the vtable entries of a class can be overridden to give the class special behaviour. I'd like to know if I'm correct (I just realized this), if I say that: you can give a variable the same behaviour by either write it as a pmc, or as class. When giving the functionality to a PMC, you write it in C, when doing it with a class, you write it in PIR. Am I correct?

Yes, you can implement almost everything a class needs inside a PIR file. Have a look at languages/lisp for a PIR-ony implementation.

If so, why then would one ever want to write a PMC (maybe for speed?)

Yep

Furthermore, if my assumption above is correct, then "morphing" and stuff works the same way?

HLLs usually don't morph their objects. Instead new objects of the desired type are returned. It's probably just perl with it's references that needs morphing. Anyway messing with PMC internals isn't exposed, you'd need e.g. call a NCI function to accomplish this task.

Thanks in advance,

klaas-jan

leo

Reply via email to