DWScript August 2012 news

Here are the recent changes for DWScript from the SVN side.

As things settle down, next version should hit RC status by the end of the month.

Language

  • Added two new forms of “for in” which are fully Unicode-capable, ie. they work for characters outside the BMP, and unlike Delphi (or Java, or C#, or JS…) are fully Chinese (and Cuneiform) capable:
    • for <integer_variable> in <string_expression> do … : enumerates Unicode code values (in the full 0 to $10FFFF range)
    • for <string_variable> in <string_expression> do … : enumerates Unicode characters
  • Introduced initial support for attributes (TCustomAttribute), currently they are accepted only at the class level.
  • Delphi compatibility: support parenthesis ( ) as an alternative to brackets [ ]when declaring constant arrays, so all the following forms are now equivalent:
    const a : array [0..1] of Integer = (1, 2);
    const a : array [0..1] of Integer = [1, 2];
    const a = [1, 2];
  • Properly qualify error when array methods are invoked on an array type rather than an instance.

Script Engine

  • Fix for some cases of sub-functions nested in a method calling another method of the parent class.
  • Fixed an optimization issue when passing object fields as a var parameter.
  • Fixed evaluation of “for in” dynamic operands (such as function calls) so they’re evaluated only once.
  • Fixed assertion message surfacing in some runtime situations.

Changes applying to SmartMS (future version)

  • Now supports class methods on external classes.
  • Optimized several cases of record copy/assignments.
  • Added peephole optimization for “Ord(str[i])” to “str.charCodeAt(i)”.
  • Fix CodeGen for static class methods of helpers.
  • Fixed cloning function for records that have sub-structures.

6 thoughts on “DWScript August 2012 news

  1. Oooo! Attributes! Very nice! When you say this is initial support and they’re currently only accepted at the class level, what else do you plan to do with them?

    Also, is there any chance we could get language support for Sets anytime soon? StringReplace is rather noticeable by its absence in the DWS RTL.

  2. @Mason Wheeler

    Mason Wheeler :

    what else do you plan to do with them?

    Support them on the rest of entities (functions, methods, properties, etc.). Beyond being able to compile Delphi code without changes, one of the first uses will be partial de-obfuscation for persistence, as well as being able to differentiate properties that are references from properties that are sub-objects during persistence.

    Some attributes could also be used as hints or optional/experimental instructions for code generation.

    They way attributes will be stored and accessed isn’t 100% nailed just yet, but the idea is to have a raw, low-level structure that holds them all, and then wrap that with Delphi-like classes.

    Also, is there any chance we could get language support for Sets anytime soon?

    I haven’t started on them (if someone wants to help, what’s needed is a set of unit tests that would “nail” how sets behave in Delphi, including syntax errors and things that shouldn’t work).

    Though if you need them for options, you can just use an “array of” in DWS, as the extended array syntax allows to create them inline with a syntax similar as sets (including “in” tests, and even “not in”). The only difference is that it won’t enforce unicity and “in” tests will be somewhat slower (not by much if you don’t have lots of options)

    StringReplace is rather noticeable by its absence in the DWS RTL.

    Hmm… Had forgotten about it as I have it there, but it’s not in the DWS SVN, as it relies on an optimized implementation (the RTL’s StringReplace is just plain crappy). I’ll see if I can move it.

  3. Though if you need them for options, you can just use an “array of” in DWS, as the extended array syntax allows to create them inline with a syntax similar as sets (including “in” tests, and even “not in”). The only difference is that it won’t enforce unicity and “in” tests will be somewhat slower (not by much if you don’t have lots of options)

    Yeah, the “enforcing uniqueness” part is the thing I miss. Include() and Exclude() are incredibly useful in a lot of cases.

  4. Hi everyone.

    Is it possible to implement “Save method” of compiled script?

    Sorry for off topic.

Comments are closed.