Hi! This blog is for news, announcements and questions regarding the
Mascara JavaScript compiler.

See also:
The online demo
Download latest release

Contact:
olav@olav.dk

Disclaimer:
ECMAScript is a trademark of Ecma International.

Powered by Squarespace
Friday
Feb272009

Mascara 1.0 beta 7 released

Includes various bug fixes and improvements.

Sunday
Feb082009

A note about warnings versus errors.

Mascara produces two kinds of messages, warnings and errors. This is similar to how compilers for other languages work: A warning indicates something that look suspicious and may be a problem, but an output program is still generated. An error on the other hand is a problem severe enough that no output program could be generated. Errors therefore cannot be ignored.

A notable difference between Mascara and compilers for other statically analyzed languages like Java or C#, is that Mascara produces relatively more warnings but less errors.

For example, referencing a variable which is not defined anywhere, will be an error in most other languages. In Mascara, however, this is only flagged with a warning, and output code is still produced.

Why is Mascara more lenient in this case? Why would anybody want to run code which contains such an error?

The reason is that in some cases it might be intended. For example, the output code can be combined with another script at runtime (in a separate SCRIPT element), and that other script may define the variable. Or the script may use the eval function which allows variable definition at runtime.

It is not necessarily recommended to do things like this, but Mascara realizes that you might be smarter than the compiler, and you may have your reasons.

So if you know what you are doing, warnings like this can be ignored.

Of course, in most cases warnings indicate problems which is indeed typos or mistakes, so it is definitely recommended to inspect the warnings closely!

Sunday
Jan252009

Beta 6 released

With fixes for some obscure bugs.

Wednesday
Jan072009

Beta 5 released

It is even better than the last version!

Thursday
Dec042008

Beta 4 released

Beta 4 fixes a few bugs, most notably destructuring assignments now works in for-each loops. This is notable since it combines two of my favorite features!

for-each loops iterates through the values of an array (or object). This is different from ordinary for-in loops which iterates through the indices (or property names) of the array/object.

For example:

for each (var x in [7, 9, 13]) write(x);
Will write 7, 9, 13. An ordinary for-in loop (without each) would write 0,1,2. In most cases the for each behavior is what you need.

Destructuring assignments "unpacks" an array or object:

var [x, y] = [2, 4];
sets x to 2 and y to 4.

Combining destructuring with for-each allows us to iterate through complex objects with a simple syntax:

var pairs = [[1,2], [3,4], [5,6]];
for each (var [a,b] in pairs) write(a+b);
I like these features because they remove boilerplate code, and makes some very common patterns clearer.

Destructuring and for-each are already implemented natively in Mozilla, by the way.

Page 1 ... 2 3 4 5 6 ... 8 Next 5 Entries ยป