Advanced Computing Environment
brix-os project page
Tetra uses inference to reduce dynamic types to static where possible.
foo = def (Type1) ... foo = def (Type2) ... bar = def (x) foo(x)
The compiler is able to infer the type of
x in the absence of polymorphism and assign function
bar with a static interface. But the above example has three possible outcomes, with the third being an
exception thrown from bar. Polymorphic identifiers should have a well defined interface that just isn't
possible with simple multiple dispatch. Combining interface types with rewrite patterns or extensions results
in a much cleaner system.
// invoke a method or property (open-style) `export-root foo = defx`open-macro (p:AnInterfaceType) -> p.foo() `export-root foo = defx`open-macro (p:AnInterfaceType) -> (typeOf p).foo(p) foo x // invoke using a function-style call `export-root foo = defx`macro (p:AnInterfaceType) -> p.foo() `export-root foo = defx`macro (p:AnInterfaceType) -> (typeOf p).foo(p) foo(x)
A controlling module defines an interface type along with the dispatch symbol and other modules may import
it and implement the required interfaces. The compiler would now be able to infer
to be of the AnInterfaceType type and any exceptions would happen at the call site instead of within
Copyright © 1995-2017 Brand Huntsman