Advanced Computing Environment
Hosted by SourceForge
brix-os project page

Previous: Contracts ----- Up: Contents ----- Next: Current Design Issues

Design Decisions

No Polymorphism
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) ->
	`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) ->
	`export-root foo = defx`macro (p:AnInterfaceType) -> (typeOf p).foo(p)


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 bar's parameter to be of the AnInterfaceType type and any exceptions would happen at the call site instead of within bar.

Previous: Contracts ----- Up: Contents ----- Next: Current Design Issues