Type Annotations ?

# David Teller (18 years ago)

I'm still working on my static analysis tool for ES4. This tool will make use of custom type (or type-like) annotations. I wonder if there are already syntax guidelines for this kind of things. I assume I should put them somewhere in comments. Should I use something like Java's @annotation tag?

# Lars T Hansen (18 years ago)

The ES4 syntax for type annotations is invariably a postfix ": type" phrase: put it on variable bindings, parameters, functions (following the parameter list).

For example,

function dot( xs: Vector.<double>, ys: Vector.<double>): double { let result: double = 0 for ( let i: uint=0, limit: uint=xs.lenght ; i < limit ; i++ ) result += xs[i] * ys[i] return result }

There are some subtleties with providing type annotations for names bound by destructuring bindings; details can be found in the proposals and are in any case forthcoming in a coherent writeup.

# David Teller (18 years ago)

The type annotations I have in mind would be related to side effects.

So, should I go for something like

function write_to_file(f : String /file_name/): void /write f/ { ... }

?