…and DWScript will likely enter RC phase before the year ends, as almost all of what I had in mind for 2.1 will be there!
Recent SVN additions since the last update:
- 75% of the DWScript core code is now covered by unit tests (this was a psychological milestone for 2.1!).
- class operators have been added, currently those are “+=”, “-=”, “*=” and “/=”, they follow a syntax similar to properties, in that a class operator isn’t defined as a special method, but as syntax sugar for a regular method (see below).
- Function call overhead has been reduced for in-script functions & methods, as well as TdwsUnit-based functions & methods.
- TProgramInfo now has ParamAsXxx[] properties, which allow accessing parameters by index and in a more efficient (is less-safe) fashion.
- Sqr() became a special function, it will now return an integer and not a float when operating on an integer.
- Various fixes and error message clarifications (thanks Alexey Kasantsev).
Class operators in DWScript
The first class operators are now implemented in DWScript, though the syntax differs from Delphi, FreePascal & Prism in that they are not special methods/procedures, but syntax-sugar aliases, in a fashion similar to what properties achieve.
class operator <operator> <rightType> uses <method>
To illustrate this with TList f.i., you could declare have
class operator += TObject uses Add; class operator -= TObject uses Remove;
and so “myList += item” would be equivalent to “myList.Add(item)”.
Note that class operators support type overloading, it is thus possible to declare
TMyClass = class procedure AddInteger(i : Integer); procedure AddString(s : String); class operator += Integer uses AddInteger; class operator += String uses AddString; end;
The method will be selected depending on the right operand type
myObject += 10; // will use AddInteger myObject += 'ten'; // will use AddString;
Only compound-operators can be overloaded, overloading of other operators is not planned for 2.1.
For 2.2 and beyond, the plan is currently to not allow overloading of non-compound-operators in the scripts (at least not without a switch to control that ability), this is to keep ambiguous uses of operator overloading out of the scripts.
Delphi-side overloading definition will however be supported for class and add-on base types, one of the first uses will likely be for upcoming (optional) vector, matrix & other algebra types.
Great work Eric!
Phew! For a moment I thought you are ‘ending’ this project, like abandoning/terminating it, LOL. Great job Eric 🙂
@Chee Meng
Yea Eric, why the hell you chosed this title?! it scared the crap out of me ROFL!!
Don’t do that again!! 😛
Eric, I hear you have a closed IDE example that shows how to get the debugging support. I asked a question on http://stackoverflow.com/questions/4556277/dwscript-can-anyone-help-with-editor-debugger-examples-please and Dorin was kind enough to point me at you here. Could you assist please? DWS looks great. Thanks.
@Brian Frost
Replied you in SO.