• Advertisement
Sign in to follow this  

Object Implementation in Script

This topic is 4424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is Object Implementation and Decleration a Planned feature? For my project it would be a necessary evil(good?), If so, I would like to offer a hand in completion of such, and if not. I would like to hear opinions about style, and implementation of such, as That is the major issue holding me back from using AngelScript Nicholas "Indy" Ray

Share this post


Link to post
Share on other sites
Advertisement
Do you mean 1st class objects or POD types?

Angelscript already has POD types available, and shortly to be released there will be functions added to script declared structs.

Share this post


Link to post
Share on other sites
Sorry, I did mean full class objects with inheretance and all the hassles that come with them.

Share this post


Link to post
Share on other sites
I'm planning on implementing class methods and constructors for version 2.5.1. The version after that will hopefully include inheritance as well for script declared classes.

For now I will pretty much follow the C++ way of doing it. In a future version, or perhaps in a parallel project, I may implement other ways of supporting object oriented programming.

Share this post


Link to post
Share on other sites
Do you think you would go the D way of inheritance? In that multiple inheritance is accomplished through mixins rather than straight multiple inheritance?

Share this post


Link to post
Share on other sites
I need to read up on how the D language implements multiple inheritance. Or perhaps you could give me an overview of how it works in D?

Seeing as I have a much greater knowledge of C++ than any other language, it is likely that I'll go with the C++ way. But nothing has been decided yet.

Share this post


Link to post
Share on other sites
I'm not strong on the D implementation, I've only skimmed the docs a few times, but the basic jist of it is that it implement single inheritance and I'm pretty positive virtual inheritance in a manner very similar to C++, except when it comes to multiple inheritance.

D provides what it calls mixins. A better explanation can be found here:

http://www.digitalmars.com/d/mixin.html

Share this post


Link to post
Share on other sites
From what I understood the concept of 'mixin' in D is not related to class inheritance. 'mixin' seems to be more like macros than anything else.

Share this post


Link to post
Share on other sites
'Mixin' is an idiom used in C++ too. D's are little more than macros. Java offers interfaces instead of multiple inheritence. As usual, C++ favors power over safety. Multiple inheritence is error prone, but more powerful than either other implementation.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement