Type Annotations ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Type Annotations ?

David Teller-3
        Hi everyone,
 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 ?

Thanks,
 David


--
David Teller ------------------------------------------
Security of Distributed Systems -----------------------
-- http://www.univ-orleans.fr/lifo/Members/David.Teller
----- Laboratoire d'Informatique Fondamentale d'Orleans

_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Type Annotations ?

Lars T Hansen-2
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.

--lars

On 10/3/07, David Teller <[hidden email]> wrote:

>         Hi everyone,
>  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 ?
>
> Thanks,
>  David
>
>
> --
> David Teller ------------------------------------------
> Security of Distributed Systems -----------------------
> -- http://www.univ-orleans.fr/lifo/Members/David.Teller
> ----- Laboratoire d'Informatique Fondamentale d'Orleans
>
> _______________________________________________
> Es4-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es4-discuss
>
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Type Annotations ?

David Teller-3
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*/ {
  ...
}

?

Cheers,
 David

On Wed, 2007-10-03 at 07:44 -0700, Lars T Hansen wrote:
> The ES4 syntax for type annotations is invariably a postfix ": type"
> phrase: put it on variable bindings, parameters, functions (following
> the parameter list).

--
David Teller ------------------------------------------
Security of Distributed Systems -----------------------
-- http://www.univ-orleans.fr/lifo/Members/David.Teller
----- Laboratoire d'Informatique Fondamentale d'Orleans

_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss