Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

angry

need feedback on script language

This topic is 5174 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

I''ve decided to write my own script-language. I''m still working in the design process and it will look much like Java. However I want my language to support operator overloading. And therefor needs some idea''s how this could look like. C++ handles it this way: SomeClass operator = (SomeClass); And the ideas I have looks like this: SomeClass assign(SomeClass); SomeClass add(SomeClass); SomeClass sub(SomeClass); SomeClass mul(SomeClass); SomeClass div(SomeClass); ie. registered method names, that will also work as operators, ie: SomeClass.assign(someOtherClass); <==> SomeClass = (someOtherClass); I hope you understand what I mean. However I would like to recieve some other ideas and some feedback on my idea. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
This is similar to the way Python does it.

Python''s operators map to ''__add__'', ''__div__'', ''__mul__'', etc.

Using a convention such as this is preferable because canonically, Collections (the supertype of all things that store arbitrary numbers of other objects) have a method called ''add'' that inserts or appends an item to a collection.

Share this post


Link to post
Share on other sites
I really suggest you allow operator overloading at least as well as unrealscript does. In it, you can define your own operators, what they act on, their precedence, etc. I''d be very nice if C++ supported such a thing.
To see how unrealscript handles it: tutorial

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!