Skip to main content
gamedev.net
🔒 Locked

need feedback on script language

Started by angry 1 reply 400+ views
Original Post
angry
angry
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.
Flarelocke
Flarelocke
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.
---New infokeeps brain running;must gas up!
Extrarius
Extrarius
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
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.