any reason that heirarchies can not be registered for value types

Started by
2 comments, last by WitchLord 11 years, 7 months ago
http://www.angelcode..._hierarchy.html
mentions that
Hierarchies can currently only be registered for reference types, not for value types.
why is it so. is it a design choice?


I mean , if i have value type(for performance reasons) of "ZFraction" and "ZIrrational" . Now i would definitely like them to be a subclass of "ZReal".
Just due to the above restriction, i will be forced to use reference type, which will make the performance poor, as it heap based.
Advertisement
Do you really need for a ZInteger to be treated as a ZFraction or vice versa through polymorphing?

It's currently not possible to do reference casts for value types, but that doesn't mean you can't register both ZInteger and ZFraction even if they are base and subclass in C++.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

ha..ha.. Actually my bad. It was a typing mistake.
I do not want the "ZFraction" and "ZIrrational" to be a subclass of "ZInteger".
I want the "ZFraction" and "ZIrrational" to be a subclass of "Real". I have edited and corrected my original question.
We keep ZFraction , because we want to store say 1/3 instead of 0.3333333333.....
but many Irrational do not have fraction representations, they may be quadratic surds etc.


Actually, I want to develop a object oriented scripted framework for high speed " mathematical computation", as it needs to be very high speed hence i am not doing it in java. I want to do it ALL in C++ classes, but only the interfaces will be exposed to angelscript. The reason i chose angelscript has nothing to do with static typing or feature x or feature y . i chose angelscript because it lets me define "my own" types(ie, value types) which will exist on "stack", not on heap, this will give me less cost to speed performance compared to heap approach. This (custom-classes on stack) is not possible in almost any of the C like syntax based scripting languages for C++, it seems to be possible only in angelscript.

But on the above said url in my question , when i was preliminarily reading . It says that if i make them value types then i can not make object oriented heriarchies in them.

my heirarchy (ZFraction and ZIrrational are subclasses of ZReal . There are other classes in this heirarchy as well ZComplex, ZNatural ) etc. All will be implemented as C++ classes as proper parent and child classes.

Now, you said in your reply that
"It's currently not possible to do reference casts for value types, but that doesn't mean you can't register both ZInteger and ZFraction even if they are base and subclass in C++."

Now, from your reply i could not understand much, that by any workaround whether you are saying its possible: yes or no .

If i expose ZFraction and ZIrrational and ZReal (originally implemtned in C++) to angelscript as VALUE TYPE, then are you saying that i can still expose child-parent relationship of ZFraction and ZReal to angelscript, even if they are value types, using some workaround? Any relevant url for this?
sorry for the trouble, but its extremely important for me.
I just don't know in what cases you will actually use the child-parent relationship for the ZFraction and ZReal types. Can you show an example? Wouldn't implicit value casts do just as well?

If you can just explain to me why there is such great need for the child-parent relationship to be known to AngelScript, then I'll look into implementing the necessary support.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement