Simon said:
> > I see. ?But what's the rational to have Bigints / Bigfloat be native types > > instead of PMCs? > > They're useful and predictable. And also, you may want to automatically > promote integers to bigints; you probably don't want to automatically > promote integers to complex types. :) > Who knows... what about sqrt(-1)? Anyway, i get your point. > > In other words, in my humble opinion (which is a not very qualified one :) > > it is a bad idea to put the language-dependent behaviour in the PMCs because > > PMCs hold user's data, and data should freely travel the language > > boundaries. > > > The right place to put language-dependent behaviour is in the opcode, which > > is generated by a language-aware compilation of this particular fragment of > > code. > > I'm afraid I have to disagree very violently with you on this one. > Well, until now your disagreement has been expressed in very gentle terms; so i wouldn't call it violent. :) Anyway, the whole point I try to express, is that making "add" have a different behaviour depending of the language that _created_ the object is wrong. Because, <add>, and <length>, and <what to do when called in scalar context>, are really properties of the perl, python, javascript, ruby, scheme, or java4parrot code that is running this very line of user-code. If you put language-dependent behaviour on the PMC, then you are definitely forced to change the type of a PMC each time it crosses a language boundary, or risk at nasty things. Maybe that's not a problem, maybe it is (speed, information loss, rich types, code complexity, etc..). There is another way of leaving the door open to other languages, and it is to keep the set of responsibilities of PMCs a bit smaller, the definition of vtable methods clear and unique and add a per-language layer (with its per-language opcodes) who takes care of implementing javascript-add in terms of standard-parrot-PMCs operations. Whatever, I understand this is a significant difference from the current state of things, so maybe a wise choice is to mantain the current behaviour of PMCs until the problems I expect become reality, and only if they really do. -angel