jsigbiz / spec

JavaScript signature notation
130 stars 6 forks source link

Tuple notation #6

Closed junosuarez closed 10 years ago

junosuarez commented 11 years ago

@raynos mentioned wanting a clearer literal expression for Array<Type> and proposed [Type] in https://github.com/jden/jsig/issues/5#issuecomment-16326982

I just was looking back through some project code and noticed myself using the same notation. However, this conflicts with Tuple notation in the draft spec.

Would it make sense to use parentheses to describe Tuples? In ES5, I'm taking that to mean arrays with specified length and specified types at each positional index. I've seen parentheses used in languages with better destructuring support, for example Scala.

Proposed: Rather than point: [x: Number, y: Number] we could write point: (x: Number, y: Number). This treats tuples as analogous to parameter lists in functions.

Raynos commented 10 years ago

I've recently stuck to [A, B] as a tuple, i.e. an array of two members and Array<Foo> as a Homogenous array.

I see tuples as being a fixed lenght heterogenous array.

Example: https://github.com/Raynos/jsig/blob/master/test/parser/integration/definitions/jsonml-stringify.mli#L23

Feel free to close if we want to keep [] as tuples and Array<T> as homogenous arrays.

junosuarez commented 10 years ago

Agreed. Let's keep what's currently in https://github.com/jden/jsig/blob/5adaabbbd13c5f296a9c1b659bf01bc1381bec71/README.md#tuples