Skip to content

Named interfaces #133

@ckknight

Description

@ckknight

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions