Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Named interfaces #133

Open
ckknight opened this issue Jul 18, 2013 · 0 comments
Open

Named interfaces #133

ckknight opened this issue Jul 18, 2013 · 0 comments

Comments

@ckknight
Copy link
Owner

Currently, one can specify specific object types as so:

let f(o as { alpha: String, bravo: Number }) ->

Which can get unwieldy if the object is too complex or if there is practically any repetition in code.

Instead, I'm proposing the following syntax:

interface Thing = {
  alpha: String
  bravo: Number
}
let f(o as Thing) ->

In the previous example, Thing would not exist at runtime and merely be a compile-time alias like C's typedef. One would be able to alias any type with a name, including functions or other interfaces or basically anything that already works in the type system.

Also, having generic support would be nice:

interface Box<T> = {
  get: -> T
  set: T -> T
}
let f(o as Box<Number>) ->
let g(o as Box) -> // the T in Box<T> represents the "any" type here, since unspecified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant