🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Object Implementation in Script

Started by
12 comments, last by Rain Dog 18 years, 5 months ago
I've been thinking about using interfaces like Java does as well. I think it's quite clean and would probably be easier to implement than full multiple inheritance like C++.

But my first concern right now is to implement single inheritance, once that is done I will make my decision on how to implement multiple inheritances.

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

Advertisement
In my humble opinion Multiple inheretance and interfaces are both clunky, often inelegant, mostly a hack, and mostly unnessacary. The D method of mixin's don't support some of the few reasons to use MI and all runtime method's require too much extra memory.

So, anyways, anything I can do to help speed along the development of objects with inheretance?

Nicholas "Indy" Ray
I agree that multiple inheritance or interfaces are in many situation not necessary, but there are times when they can help a lot and make the code much cleaner. They are just a tool for writing the code, and it's up to the programmer to choose the right tool for the right job.

I think it will be difficult to coordenate any joint effort on this feature as it is rather small. But you're welcome to work other features and then send them to me as contributions.

If you have access to a 64bit system, then I would very much appreciate help in identifying what needs to be changed in order to add support for 64bit processors.

Another feature that I want to improve is the 'any' type. I intend to have this type be able to store any type, not just object handles. I also intend to allow the use of the any type with operators such as math ops, etc. If you feel like working on that, then you're more than welcome.

Regards,
Andreas

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

The D Mixin classes can be used in a way to simulate multiple inheritance very easily.

You simply create a mixin that acts as a proxy to an instance of the class you want to inherit from, that way. I suppose this could be done just as easily with a preprocessor macro too. But this method would take the repetition out of having to declare/implement an interface, or having to write the forwarding functions for composed objects.


That to me is the biggest advantage of multiple inheritance. If you look at WTL/ATL libraries, they use it everywhere, and it seems to get the job done real well.

Also, something else that might be worth looking into is the ruby duck typing system. (Ruby was not I believe the first to do this) which is basically this: If an object has a method named Foo, and you want to call a method named Foo, then it doesn't matter whether the object is of type X or Y, it has a Foo, so lets use it.

This topic is closed to new replies.

Advertisement