Home > News > DWScript 2.1 preview 3 – now with type inference

DWScript 2.1 preview 3 – now with type inference

September 30th, 2010

A DWS 2.1 preview 3 7z archive is available at googlecode Delphi Web Script page, you can also get the same code via SVN of course.

This versions fixes several reported and unreported  issues, and adds support for type inference and Delphi Prism variable initialization syntax. Before you could write code like:

var myInteger : Integer = 1234;
var myObj : TSomeObject = TSomeObject.Create;

where ‘=‘ was used as assignment operator (using the same syntax as for constant declaration or default parameter values), you can now write the above using ‘:=‘ as well

var myInteger : Integer := 1234;
var myObj : TSomeObject := TSomeObject.Create;

and you additionally can make use of type inference and write just

var myInteger := 1234;
var myObj = TSomeObject.Create;

Type inference is currently limited to the variable declaration, this will probably stay for code clarity (opinions?). The inferred type isn’t restricted at the moment, but that will probably change (so you can disallow to inferring to a Variant type f.i.).

News

  1. Robert Noble
    September 30th, 2010 at 21:58 | #1

    I haven’t seen in your example programs anywhere how to externally call a function defined with in the script.
    ie. MyScript.Execute(functionName,FunctionParameters,Result);
    Does DWScript have this ?

  2. October 1st, 2010 at 05:56 | #2

    This is wonderful, great job!!
    can I expect a simple web example using DWS?! thank you!!

  3. October 1st, 2010 at 08:15 | #3

    Yes, it’s possible, I’ve quickly imported the old first steps doc from DWS2
    http://code.google.com/p/dwscript/wiki/FirstSteps
    it should still be relevant and correct – if incomplete – typos excepted of course.

  4. October 1st, 2010 at 08:17 | #4

    Surprising as it may seem, I haven’t been using DWScript for strictly web purposes with the htmlfilter, so I don’t any sample website handy, so all there is right now are the htmlfilter unit tets. There may be one or two samples in the old DWS2 repository, if someone care to bring it/them up to speed.

  5. October 2nd, 2010 at 00:42 | #5

    @Eric I was just curious… how would one user DWS on a web server… I mean best approach…

  6. Robert Noble
    October 2nd, 2010 at 06:58 | #6

    I tried to call the internal functions but kept getting
    a nil pointer for Prog.Info. until Debugging through your code I figured it out.
    The Prog.Info is nil if you call Prog.execute;
    The example should be :
    Var Prog : TdwsProgram;
    prog:=DelphiWebScript.Compile(memo1.lines.text);
    Prog.BeginProgram();
    sTemp := prog.Info.Func['test'].Call([i,j]).ValueAsString;
    Prog.EndProgram;

  7. October 2nd, 2010 at 14:30 | #7

    @Robert Noble
    Thanks, I’ve made a quick mod to the wiki page, more details will go in a demo when I have time.

Comments are closed.