Lambda functions in TIScript

I’ve added new short notation for anonymous (lambda functions) in TIScript build #2.0.0.3 Example of such notation – sort array a in descending order: a.sort(:v1,v2:v2 – v3); This is a direct equivalent of: a.sort( function(v1,v2) { return v2 – v3; } ); Therefore anonymous functions in TIScript can be declared in place in of the…

Terra Informatica Script v. 2.0

TIScript v. 2.0 has been published. New features, language: Built-in persistent storage, classes Storage and Index by Alexei Marinets. Built-in XML/HTML tokenizer class. It is based on my code from article on CodeProject Improved memory management. New features, API: API ::TIS_define_class – allows to define native packages and classes. See struct TIS_class_def in tiscript.h file….

Color-chooser, part III. Prototype… of what?

This is a continuation of: Color-chooser, part II. Three pieces of the Puzzle. First of all:  Sciter executes scripts after completion of document tree parsing. This is major difference from how conventional browser deals with scripts. So script execution in Sciter is deterministic – code in script files executed when DOM is loaded and in…

What the hell is that JSON-DB?

JSON-DB… You can, probably, guess that it’s a compound word, which consists of JSON and DB (database). And you are absolutely right! It’s a way to save javascript objects in a persistent storage. Let’s imagine that you have a state object in javascript, which you’d love to persist. And the state consists of different objects…

Eval, JSON and curly braces.

Say, you have JSON data (object literal) stored as a string somewhere: “{ one:1, two:2 }” and you want to parse (convert) this string into scripting object. Obvious solution for this would be to write something like this: var dataStr = “{ one:1, two:2 }”; var data = eval( dataStr ); Looks nice and simple…

Delegates in JavaScript. Now with parameters.

Here is an extended delegate function: function delegate( that, thatMethod ) { if(arguments.length > 2) { var _params = []; for(var n = 2; n < arguments.length; ++n) _params.push(arguments[n]); return function() { return thatMethod.apply(that,_params); } } else return function() { return thatMethod.call(that); } } And here is an example. Note that obj.method now accepts additional...

Delegates in JavaScript

Simple definition: delegate is a value – reference to the pair of object and its method. Lets name them as delegate.object and delegate.method. delegate invocation is a way of calling of delegate.method in context of delegate.object. So inside code of the delegate.method variable this points to the delegate.object. To be practically useful delegate in JavaScript…