DWScript news roundup July 2013

dws-mirrorHere is a summary of DWScript changes since the last update.

Language enhancement are centered around several additions for enumeration elements and sets, as well as a standard Map() method for arrays. The JIT compiler also got more capable, and there were various improvements to the support libraries and compatibility with older (D2009) and newer (DXE3) Delphi versions.


    • dynamic arrays now support the Map() method, that maps an array’s items to a new array after going through a user function, f.i. “floatArray.Map(Sqrt)” will return a dynamic array where elements are the square root of the elements of the original array.
    • enumerations elements now have a Name property, which returns their name, so you can write code like
      type TEnum = (enOne, enTwo, enThree);
      for var e in TEnum do

      Note that this works even on discontinuous enumeration (and thus doesn’t have the limitation Delphi’s GetEnumName has)

    • enumeration elements now have a Value property, which returns their numeric value, and can serve as a more expressive and discoverable alternative to the Ord() special function.
    • for element in set” is now supported
    • Trim() has a new overload Trim(nbLeft, nbRight) where the parameters specify the number of characters to trim on the left & right of a string

. It can be used both as a helper method or as a function (with the string to be trimmed as first parameter).

  • Made the compiler error reporting more resilient to several special cases of invalid expressions.

Just-In-Time compiler

  • improved support for sets (include, exclude, in, for in), including large sets
  • “for to step” is now supported
  • bitwise integer ops are now supported
  • meshing of JIT code with still-unsupported expressions has been improved, meaning that you’ll see JIT benefit in more cases, even when not everything is supported
  • fixed support for Sqr (which went missing for a couple weeks, and slowed down the Mandelbrot benchmark)


  • improvements to the “name parser” in TdwsUnit, that allows declaring members using a classic code-like syntax rather than adding elements manually in the collections (thanks CW Budde)
  • Packages and code were updated and made compatible with Delphi 2009 and XE3 (thanks Hallvard Vassbotn)
  • code suggestions class received multiple improvements, both in terms of reliability and accuracy
  • fixes and expanded support for the UIB driver
  • faster integer to hexadecimal conversions
  • added WriteToStream in dwsJSON

Script engine

  • reduced function call overhead (and improved execution performance)

5 thoughts on “DWScript news roundup July 2013

  1. It’s a pity, that you don’t work for EMB on the Delphi compiler. I realy like your language enhancements.

  2. “improvements to the “name parser” in TdwsUnit, that allows declaring members using a classic code-like syntax rather than adding elements manually in the collections”

    Could you elaborate this one, possibly with a topic in wiki so it is documented?

  3. @ain yes, an article about it is coming, until then you can have a look at the TdwsUnit tests in the source. It basically allows you to type things like a function declaration in its “Name” field at design time in Delphi, the declaration will be parsed and fill the various actual fields. This can be a lot more convenient to do it that way whenever you have parameters, as it minimizes the clicking in the Delphi component editor and structure view.

  4. Mandelbrot Demo again fast:

    Revision from 2013-05-12:
    Delphi 324.2 ms – DWScript 207.7 ms (inc. compilation)

    Revision from 2013-06-05 (R2157):
    Delphi 283.3 ms – DWScript 1345.7 ms (inc. compilation)

    Revision from 2013-07-11 (R2212):
    Delphi 286.1 ms – DWScript 203.9 ms (inc. compilation)


Comments are closed.