Milescript classes which have the "external" modifier can now also
have a "nameless" modifier. In addition, if a class is "external" it
may have an "at" keyword after any "extends" and "implements"
statements. Following the "at" keyword can be either a DotExpression
inside of parenthesis, a "declared" keyword inside parenthesis, or
just the "declared" keyword.
For example, an ECMAScript object you wish to interact with may be
nested several layers deep within another ECMAScript object. Here is
an example in JavaScript.
var feed = new google.feeds.Feed(someUrl);
The external Milescript class declaration would look like this.
package some.package;
public external class Feed at (google.feeds) {
public Feed(String url) { }
}
Note that the Milescript class can be in whatever Milescript package
you choose, regardless of the generated JavaScript namespace.
The Milescript class could also be written as such...
package google.feeds;
public external class Feed at declared {
public Feed(String url) { }
}
This would use the package name in the generated ECMAScript.
Either Milescript implementation will generate the following
ECMAScript...
Milescript:
GoogleFeed feed = new Feed(someUrl);
ECMAScript
var feed = new google.feeds.Feed(someUrl);
The nameless keyword allows you to wrap ECMAScript functions which
appear in the root namespace. It can also be used to divide the
functionality of an external object into separate Milescript classes.
Milescript class:
package some.package;
public static external nameless class window {
public external void alert(String someString);
}
The alert function can be used in Milescript like so...
window.alert("HelloWorld!");
This will generate the following ECMAScript...
alert("HelloWorld!");
This is just a small example. A more detailed document is in the
works.
- Greg Youree