DWScript news roundup for June 2013

dws-mirrorHere is a summary of recent changes, language highlights are initial support for sets and a new Sort() method for dynamic arrays.

Apart form Linq & LLVM libraries which were previously mentioned, Brian Frost made multiple updates to the IDE Dialog. There were numerous other minor fixes and improvements, related to stability, performance and compatibility with Delphi code.

Language

  • initial (and limited) support for “set of”, current limitations are
    • you can only have sets of an enumeration (no size limit but memory)
    • you can initialize them from constant values
    • Include/Exclude are supported both as function and as a methods
    • the “in” operator is supported
    • set operators (+, -, <= etc.) and “for in set” aren’t supported yet
  • dynamic arrays now have a Sort() method
    • it takes a comparison function between two elements and performance a QuickSort (will likely later be changed to a MergeSort or another stable sort)
    • dynamic arrays of Integer, String & Float also have parameter-less natural Sort() method, which is optimized, and should be faster than “TArray<T>.Sort” in most scenarios
  • cross Pascal support improvements
    • the DWSCRIPT conditional is defined by default, it can be used to facilitate writing code that cross-compiles with Delphi, FreePascal or Oxygene.
    • a new CompilerVersion constant is defined by default, it’s a floating point value that holds the compiler version in language terms under the form YYYYMMDD.XX, with XX the minor version. This will be updated each time the language changes
  • Delphi code compatibility
    • “program” is now accepted as the beginning of the main program, and will trigger classic code parsing (ie. with var/const blocks, but no inline code until the first “begin”)
    • the “inline” qualifier is now accepted by the compiler (Delphi compatibility, currently not made use of by the engine)
    • unfinished multi-line comments encountered in includes are now reported as errors (same as Delphi)
  • Ord(string) now decodes UTF16 surrogates
  • fixed an issue with break/continue not being allowed in “for x in string” loops
  • fixed an issue with parenting of forwarded partial classes
  • fixed an issue on implicit calls on function pointer fields that have no parameters

Script engine

  • added IdwsCompiler interface so that language extensions can delegate sub-expressions parsing back to the compiler
  • improved performance of dynamic arrays IndexOf method
  • optimized “string in string” operator
  • conversion from UTF8 to explicit “UnicodeString” for FreePascal compatibility (work in progress)
  • improved Factorial() performance

Libraries and tools

  • Linq library by Mason Wheeler
  • LLVM codegen by Christian Budde
  • Improvements to the IDE Dialog by Brian Frost
  • Improvements to suggestions (completeness and performance)
  • New TQuickSort utility algorithm
  • Improved performance of dwsGlobalVars
  • minor fixes for DatabaseLib, dwsJSON, dwsDirectoryNotifier

7 thoughts on “DWScript news roundup for June 2013

  1. Eric, keep it up!
    Christian just don’t drop llvm codegen progress!
    Now, i really start to believe that dws can become the next delphi, or even more then just delphi!

  2. “set of” enumeration is something I expected since the beginning in DWS.

    I usually (ab)use of this nice pascal syntax, which can be very powerful when dealing with business rules for instance (to define the “ubiquitous language” of Domain Driven Design for instance).

    Enumerations and sets are something I miss very much in C#, which is tied to old C enumerations.

    Enumerations and sets are something which can benefit a lot of being JITted.

    Thanks a lot!

  3. Eric.
    Why Mandelbrot Demo six times slowed down?

    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)

  4. Sqr was changed from a special (compiler-based) functions to a standard overloaded functions, and the new one didn’t have JIT support yet. They do now.

Comments are closed.