tirsdag den 22. juli 2008
Abonner på:
Kommentarer til indlægget (Atom)
This blog has moved to http://blog.mascaraengine.com. See you!
This blog is (was) for news, announcements and questions regarding the
Mascara ECMAScript 6 -> JavaScript translator.
This blog is (was) for news, announcements and questions regarding the
Mascara ECMAScript 6 -> JavaScript translator.
12 kommentarer:
Hi Olav,
function references within classes don't appear to compile with the new version.
i.e.
this will compile fine:
function test1()
{
var test11 = function() {};
}
but this won't:
class test2
{
function test1()
{
var test11 = function() {};
}
}
and the same with this:
function test1()
{
var test11 = function() {};
}
class test2
{
function test21()
{
var test211 = test1;
}
}
I'm using your compiler to learn ecmascript4...so is this expected handling in the language?
Thanks for the great work!
Hi boniestlawyer,
you have discovered a bug. I have uploaded a new version, 0.4.1, with a fix. Thank you very much for reporting thing.
Nice to hear that you find the compiler useful. Hope you have fun with it!
Olav,
You're doing awesome work!
Just curious: what changed between 0.3 and 0.4?
-- Peter Rust
Apart from the new bugs you mean? :)
- Triple quoted strings and multiline regexes.
- Function expression signature can now be annotated to indicate the type "this" inside the function.
- prototypes now shared between int/float/Number, string/String and boolean/Boolean.
I'll write a blog post detailing the new features when I get time.
Thanks for the nice words!
Hi Olav,
Is it possible in the current state to cast a value as an inherited type. Example:
import browserapi;
import htmldom2;
var e : HTMLSelectElement
= document.createElement("select");
This throws the warning: Variable e of type HTMLSelectElement is not compatible with expression documentselect (HTMLElement)
Hi boniestlawyer, you have to write:
import browserapi;
import htmldom2;
var e : HTMLSelectElement
= document.createElement("select")
cast HTMLSelectElement;
BTW, if you feel that the redundant HTMLSelectElement is redundant, you can just write:
var e = document.createElement("select")
cast HTMLSelectElement;
The compilers then figures out that the type of e is HTMLSelectElement.
wow, that's awesome, thanks olav!
> I'll write a blog post detailing
> the new features when I get time
No worries. I don't mind if the blogging is a bit sparse if that means you're spending more time coding! (eagerly awaiting Array Comprehensions and Operator Overloading)
-- Peter Rust
Hi Peter,
I'm afraid it seems like operator overloading has been removed from the current draft of the ES4 spec. Perhaps it will reappear in a later version.
Array comprehensions are a priority though, since they are also one of my favorite features :-)
Hi there. Do you know if the "module" pattern that is used in existing Javascript will work with the namespaces of ES4?
For instance, if I try:
namespace foo;
(function() {
foo var bar = 10;
})();
foo::bar;
It errors out saying 'bar' is not defined at Program scope for namespace 'foo'. Which makes sense, since 'bar' is defined in the anonymous function. However, how could I add something to the 'foo' namespace from within the anonymous function?
Thanks :)!
Hi Anonym,
That is an interesting issue.
It seems that what you propose is not possible. You cannot define a global variable in a namespace from inside a non-global scope. I'm not yet sure it this is intentional or an oversight in the spec.
However, namespaces are intended to solve the same problem that the module-pattern intends to solve (that is, avoiding name clashed between modules), so I guess you wouldn't need to use both at the same time.
Send en kommentar