zot / Leisure

Polyglot, document-based computing environment. Leisure is very much in flux, right now; please check the readme, below. For a taste of the new version, click the link below, but be warned that it only works in Chrome.
http://zot.github.io/Leisure/?load=elisp/README.org
Other
114 stars 8 forks source link

Type constraints, subtyping, and polymorphic functions #33

Closed zot closed 12 years ago

zot commented 12 years ago

-- Should this just be full pattern matching, with first-arg type constraints being just an optimization case?

Type constraints:

Introduce type constraint operator, '::', like in Julia. This means to use the dispatch mechanism when calling the function. Calls to polymorphic function with unhandled type produces an error, so this also provides type checking.

printString x::list = printString-list x

Subtypes -- used in dispatch and type constraints

subtype type subtype -- monad to declare a subtype

isSubtype type subtype -- returns boolean

JS prototypes

Dispatch on first arg can be implemented as JS method

Dispatch on other args can be done like in Xtend

zot commented 12 years ago

Implemented polymorphism and nixed subtyping. I think that subtypes don't add anything.