DWScript July 2012 news

Here is a summary of recent changes since the last news roundup.

These apply to the SVN version, which will likely become 2.4 soon, as it includes quite a bit of improvements and fixes over 2.3 (which was released in march).


  • Added support for initialization and finalization for units, unlike with Delphi, you’re allowed to declare variables in those sections.
  • Added support for deprecated for properties.
  • Delphi compatibility; accept “class helper” syntax, also added “interface helper” and “record helper“, which restrict the allowable types for a helper. Unqualified helper declaration is unchanged and still allows helpers on any type.
  • Delphi compatibility: accept “reference to” and “of object” for function pointers/delegates declarations, the compiler just ignores them, as functions pointers are unified in DWScript.
  • Added Swap() internal magic function, Swap(a, b) will swap the values of a & b as efficiently as possible, and works for all types (arrays and records included).
  • Added StrToBool() to the standard functions.
  • Added hint about private functions that are marked “virtual” (likely error, since they aren’t overridable).
  • Added “pedantic” hints about parameters of class type that are passed as const.
  • Fixed resolution of “=” and “<>” overloaded operators when applied to classes.

Script Engine

  • Reduced compiled scripts memory usage (by 5 to 25%), also reduced script runtime objects memory usage slightly.
  • Added an explicit lock to TDelphiWebScript to prevent multi-threaded compilation (multithreaded execution of compiled programs is not affected). A particular instance of TDelphiWebScript can only perform one compilation at a time, but you can have multiple instances of TDelphiWebScript to perform multiple compilations at the same time in different threads.
  • Fixed a very rare bug in parameter passing that could occur for some combinations of parameters and memory allocations, it could result in spurious script errors that were almost impossible to reproduce.
  • Fixed a bug with temporary space allocation for some methods

Support tools and classes

  • Refactored and cleaned up the SourceFile list of compiled programs, fixed compiled line count for script involving includes and units.
  • Fixed parsing of Unicode literals in the JSON support classes (characters specified by code rather than in the text)
  • Fixed some methods in the SymbolDictionary that were case sensitive

Changes applying to SmartMS (for v1.0.1 and beyond)

Beyond v1.01

  • Devirtualization support, it allows a reduction of compiled JS size, and can give a small execution speedup. It also means it’s now harmless to mark methods as virtual even if they’ll only be very infrequently overridden.
  • Sourcemaps and “debugging” source files support is being tested (allows to debug a compiled application right in Chrome Dev Tools or FireBug on the Pascal source code, placing breakpoints and watches in your Pascal source, with JavaScript only appearing as the CPU view would in Delphi)
Included in v1.0.1
  • Date/Time functions are now supported on the JS side, offering a floating-point based date time which is compatible with TDateTime
  • Fixed publishing of record properties that map to class functions, class vars or class consts
  • Fixes and improvements for Integer() and Float() casts
  • Fixed constructing sub-classed externale classes


3 thoughts on “DWScript July 2012 news

  1. I like very much the debugging feature to be included within Smart.
    Would make development much easier!

    I was not able to find up to date documentation for DWS.
    For instance, there is no reference to “helpers” in the project Wiki.

    Thanks for the good work, especially for the performance/memory enhancements. This is not so common in those days of cloud computing and insane hardware… but it does make sense, and is a good way of increasing profit: for instance, a faster server will server more clients, so would be able to get more income, with the same HW investment.
    And, IMHO speed search is just fun. 😉

Comments are closed.