Suggestions

Nicolas Cannasse ncannasse at motion-twin.com
Wed Jun 28 09:33:10 PDT 2006


Hi,

I've been talking with Brendan a few weeks ago and I made some 
suggestions about ES4. I'm copying them here so they can be discussed 
publicly. They are mainly related to the specific usage I'm making of 
Javascript but might be useful for all kind of ES4 users/hackers :

- A full reflection API. See for example the Reflect haXe class : 
http://haxe.org/api/Reflect. It has to use some tricks. In particular 
the difference between an "object field" and a "prototype field" is not 
very clear in JS, so for instance to get the "object fields" you need to 
build a list with for...in then filter with hasObjectProperty.

- how you will support interitance ? Will you be able to create your own 
prototype-chains ? In haxe you can "implements" classes. Be able to add 
add object in the subtyping relation would help.

- the ability to create "naked" objects, with no prototype, and no magic 
field, so every field of the object can be freely manipulated. It would 
be nice to be able to idenpendantly set the object prototype and set the 
"field" prototype. For instance Neko gives prototype access through 
primitives $objgetproto and $objsetproto instead of giving "magic" 
access through .prototype or __proto__.

- exceptions with complete stack traces : not as strings but as objects, 
so we can easily extract the line numbers and replace them by the 
original language file/line numbers. That can also be implemented by the 
ability to add specific comments in generated code, such as :

#line MyClass.hx:203

(similar to OCaml Camlp4)

- "magic" fields __resolve, __call and __get/__set (array accesses) 
would help to implement several kind of highlevel features transparently.

- true continuations (à la Ruby) would help to implement some highlevel 
features such as microthreads and scalable event systems

- be able to manipulate Strings as array of bytes (and not only as UTF8 
chars) would be great for binary protocols. For example Firefox allows 
\0 in strings, not IE or Flash.

- block-context : you introduce that with "let", so I think it will make 
it within TG1 ? Right now haXe for instance is renaming variables to 
make them unique. (since then, I've been completing full block-level 
variables emulation for JS and Flash)

- gotos : would permit to efficently generate pattern-matching without 
bloating the code.

Nicolas



More information about the Es4-discuss mailing list