-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
Haxe has some subtle differences from TypeScript and EcmaScript 4 (inexistent) syntax.
- For aliasing types, TypeScript choose to use the context keyword
typerather than a reserved wordtypedef. EcmaScript 4 too was going to usetype(whether in ES4 it was going to be contextual or not I don't remember, though the EcmaScript 4 reference interpreter is available in archive.org). - In TypeScript, you can express
Array<T>asT[]. In EcmaScript 4 you would be able to expressArray.<T>as[T]. To me, it seems like the EcmaScript 4 syntax for specifying array types in brackets is cryptic and readable at the same time.- Both TypeScript and EcmaScript 4 express tuple types with the same syntax, consisting of two or more element types.
- In TypeScript, the dynamic type is written
any. In EcmaScript 4, it's written*.
More specifically, in these languages, type is reserved when it's followed or preceded by another identifier or reserved word, so it doesn't break compatibility.
Here's a Haxe version:
var a:Array<Dynamic> = [];
typedef DoublePrecisionFloatingPoint = Float;Here's an EcmaScript 4 version:
var a:[*] = [];
type DoublePrecisionFloatingPoint = Number;I think it'd be interesting if Haxe supported the same ES4 syntax for clarity, considering it'd not break compatibility. It doesn't break macros, does it? After all, Haxe was inspired by ES4.
Another thing I didn't mention is that the decorator syntax of ES4 used brackets, not @:.
kLabz, haxiomic and N3rdL0rd
Metadata
Metadata
Assignees
Labels
No labels