Leopold Toetsch wrote:

Sam Ruby wrote:

Leopold Toetsch wrote:

cvsuser     04/12/15 02:36:29

  Modified:    .        vtable.tbl
  Log:
  stub in object vtables

[snip]

  +void add_parent(PMC* parent)
  +void become_parent(PMC* class)
  +INTVAL class_type()
  +void add_method(STRING* method)
  +void remove_method(STRING* method)
  +STRING* namespace_name()
  +PMC* new_singleton()
  +PMC* get_anonymous_subclass()

Cool. Are there plans for opcodes? I could make use of add_parent and add_method...

add_parent has already an opcode C<addparent>. add_method should probably get one, yes. But add_method is a bit more complicated. It's called automatically during bytecode loading, *if* the class is already existing. E.g.


   .namespace ["Integer"]
    .sub hex method

but the problem is code like this:

   newclass cl, "Foo"
   ...
   .namespace ["Foo"]
   .sub foo method

now the class isn't constructed, when the bytecode is loaded and the old Parrot_store_global is used. But if you load the method code with load_bytecode again add_method is called.

My need is to be able to call add_method for methods defined as @ANON.

From the perspective of Parrot, namespaces should be viewed a perfectly reasonable mechanism for implementing classes, and there perhaps should even be special support for enabling classes to be defined that way... but: there should be no built in assumptions that all classes are defined in this way.

- Sam Ruby

Reply via email to