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); PrintLn(TEnum.enOne.Name); PrintLn(enTwo.Name); for var e in TEnum do PrintLn(e.Name);
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.
- 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
- reduced function call overhead (and improved execution performance)