"If a feature is not documented, it does not exist"
Saturday, February 6, 2010 at 12:31PM The documentation for Mascara is not yet completely perfect, but now at least we have a list of keywords!
Olav |
Post a Comment |
Hi! This blog is for news, announcements and questions regarding the
Mascara ECMAScript 6 -> JavaScript translator.
See also:
The online demo
Download latest release
Contact:
olav@olav.dk
Disclaimer:
ECMAScript is a trademark of Ecma International.
Articles:
Saturday, February 6, 2010 at 12:31PM The documentation for Mascara is not yet completely perfect, but now at least we have a list of keywords!
Monday, January 18, 2010 at 05:17PM A major advantage of statically typed languages is support for code completion. Code completion is the editor-feature where the editor suggest relevant names (variable names, method names etc.) based on what is defined and allowed in the current context - as you type. This has the potential to greatly enhance productivity. For example, you dont have to look up method names in the source or in documentation, but can just type a dot and see what methods are defined for the current object. This also helps prevent typos in identifiers.
As a proof-of-concept I have implemented code completion in the online "try-it" editor over here. Of course the online editor is not suited for serious use, but it does provide a nice showcase for what is possible.
Code completion is disabled in the editor by default. It is enabled by clicking the "magic wand" icon leftmost in the toolbar. (The suggestions may be somewhat slow to appear, since the editor has to hit the server to get the suggestions.)
An example of how it looks when i start writing the letter "f":

You can cycle through the suggestions using the up/down arrow keys. A suggestion is selected by hitting enter, or clicking it with the mouse.
The suggestion box appears automatically when you start typing, or it can be forced to show by pressing control+space.
A limitition in the current implementation is that the autocompletion usually wont work if there is compilation errors in the code. We are working on that issue.
A related experimental feature is support for documentation comments. If a variable or function is preceeded by a comment starting with /** (note: two stars rather than the usual one), the content of that comment is displayed as help related to the suggestion for the function. As in this example:

(Tags like what is known from doc-comments is Java or C# is not supported yet, though.)
Any feedback welcome!
Monday, September 14, 2009 at 03:30AM Useful and detailed error messages have always been a priority in the design of Mascara. I believe good error messages means a lot for the day-to-day productivity when using a language tool such as this.
Therefore it has always been a bit embarassing with the generic "Parser error at or near..." message in the case of syntax errors.
It just tells you that some character is wrong, not what you are supposed to write instead. Especially when learning a new language this can be infuriating. Particularily for people (like me!) who like to explore by trial and error.
In the latest Mascara release, parser error messages have been improved so they now suggest what syntax would be allowed instead of the erroneous character.
E.g. if you write
class {}
You get:
Syntax error. Unexpected '{'. Expected identifier
This tells you that an identifier is required after the keyword "class", which is hopefully a lot more useful than just the message "Parser error at or near '{'".
In many cases multiple options are legal at a given point. If you write:
class A()
The compiler will report:
Syntax error. Unexpected '('. Expected one of: '!', 'implements', 'extends', '.<', ';', '{'.
That is quite a number of tokens to choose from, but hopefully it gives a much better hint about how to fix the syntax error.
Sometimes it can be slightliy less obvious where the actual error is. Consider this:
var x =
var y = 100;
In this example I forgot to finish the first line. However the compiler will flag the "var" on the second line with "Unexpected var. Expected expression." This is because it would be legal to have the assignment value on the next line - but then "var" is not a legal expression, which causes an error.
In general it is a difficult problem to give helpful error messages for syntax errors, but hopefully these improvements is a step in the right direction, and will make it more fun to explore the language by trial and error.
Thursday, September 10, 2009 at 05:39PM Access modifiers (private and public) are among the most frequently requested features. They are now supported in the latest Mascara version, 1.2.4 (Download).
A private member is accessible only by methods in the same class. A public member is accessibly by everyone, just as members always are in classic JavaScript.
class A {
public function famous() {};
private function secret() {};
private function test() {
famous(); //OK because famous is public
secret(); //OK because we are members of the same class
}
}
var a = new A();
a. famous(); //OK
a. secret(); //ERROR, secret is not accessible from here
Members are public by default.
Static members can also be private. Private static methods can access private instance members in the same class and vice versa.
Constructors can also be private. With a private constructor it is not possible for other classes to create instances of the class. Static methods on the same class are then used to instantiate and return instances of the class. This can be used to implement patterns like singleton and factory.
Have fun with encapsulation!
Wednesday, September 2, 2009 at 07:06AM Mascara is now availably built for Python 2.6 (the latest, recommended version of Python). Versions built for Python 2.5 is still available. If you dont know which Python version you have, you most probably have Python 2.6.