Re: Returning a new PMC from ops

2002-12-20 Thread Leopold Toetsch
David Robins wrote: On Thu, 19 Dec 2002, Leopold Toetsch wrote: Well, what I was getting at was that if dest is, say, a RomanNumeralInteger whose value is "mcmlxxxiv", I don't want it to waste time converting that to the integer 1984 when I morph it to a PerlInt, if my next step is to unilate

Re: Returning a new PMC from ops

2002-12-19 Thread David Robins
On Thu, 19 Dec 2002, Leopold Toetsch wrote: > David Robins wrote: > > This method is primarily used when the interpreter has need of > > coercing a PMC to a particular type, and isn't meant as a general > > purpose casting tool. Compilers should only emit valid > > transformations. > > which d

Re: Returning a new PMC from ops

2002-12-19 Thread Leopold Toetsch
David Robins wrote: On Thu, 19 Dec 2002, Leopold Toetsch wrote: In pdd02_vtables.pod morph() is defined to do exactly this. This method is primarily used when the interpreter has need of coercing a PMC to a particular type, and isn't meant as a general purpose casting tool. Compilers sho

Re: Returning a new PMC from ops

2002-12-19 Thread David Robins
On Thu, 19 Dec 2002, Leopold Toetsch wrote: > David Robins wrote: > > On Wed, 18 Dec 2002, Leopold Toetsch wrote: > >>morph "dest" to be a "ret"? > >>unimplemented, unused, but your examples seems to be a typical test case. > > "dest" could be any type, so it's not reasonable to expect any typ

Re: Returning a new PMC from ops

2002-12-18 Thread Leopold Toetsch
David Robins wrote: On Wed, 18 Dec 2002, Leopold Toetsch wrote: always compare ids (vtables may change) - yes, many pmc's do like above, but will need changes too. What do you mean by ids? pmc->type()? Yes, ->vtable->type(). morph "dest" to be a "ret"? unimplemented, unused, but yo

Re: Returning a new PMC from ops

2002-12-18 Thread David Robins
On Wed, 18 Dec 2002, Leopold Toetsch wrote: > David Robins wrote: > > if(value->vtable == &Parrot_base_vtables[enum_class_Vec2D_in_Y_plane]) { > > always compare ids (vtables may change) - yes, many pmc's do like above, > but will need changes too. What do you mean by ids? pmc->type()? > >

Re: Returning a new PMC from ops

2002-12-18 Thread Leopold Toetsch
David Robins wrote: What's the cleanest way to return a new PMC from an op? e.g. Suppose I have a Vec2D_in_X_plane and a Vec2D_in_Y_plane and I add them and want to always produce a Vec3D - is this correct (and is it efficient?): void add(PMC* value, PMC* dest) { if(value->vtable == &Par

Returning a new PMC from ops

2002-12-18 Thread David Robins
What's the cleanest way to return a new PMC from an op? e.g. Suppose I have a Vec2D_in_X_plane and a Vec2D_in_Y_plane and I add them and want to always produce a Vec3D - is this correct (and is it efficient?): void add(PMC* value, PMC* dest) { if(value->vtable == &Parrot_base_vtables[enum_