Michal Wallace writes: > On Tue, 2 Dec 2003, Dan Sugalski wrote: > > > *) Creating new objects involves calling the ->init vtable entry *on > > the class*. Because of this each class gets a custom vtable where the > > init method has been swapped out for one (from objects.c) that > > creates a new object instead. > > Well, cool! How do I this from parrot? > > I've been trying things along the lines of: > > .sub _main > .local object Cat > .local object felix > newclass Cat, "Cat" > P2 = Cat > S0 = "init" > callmeth > felix = P0 > #... > end > .end
Should go something like this: .sub _main .local object Cat .local object felix newclass Cat, "Cat" find_type $I0, "Cat" felix = new $I0 # ... .end But note that objects are unfinished. I ran into a certain problem when I assumed that attributes could be any type of data; not so -- they can only be integers (at the moment). I needed object support right away, so I simulated using a hash. The hash has a "CLASS" key which holds the class to which it belongs. I then use this to get the methods. Luke > ... But haven't figured out the magic formula yet > That code above gives: > > Method 'init' not found > in file '(unknown file)' near line -1 > > > (If anyone can post a working example of the code > above I'd really appreciate it!) > > > Sincerely, > > Michal J Wallace > Sabren Enterprises, Inc. > ------------------------------------- > contact: [EMAIL PROTECTED] > hosting: http://www.cornerhost.com/ > my site: http://www.withoutane.com/ > -------------------------------------- >