Local Variable Type Inference

SmallDragon can infer the type of a local variable for you, so it is optional to declare the type.


fn main () ~> int {
	a = 3;
	return a;

Drawbacks of using Type Inference

This type inference has a compile-time cost (time needed to infer the type) which rises with the size of the expression.

The type of '3+4' can be quickly computed, the type of '3*(call1(3,3)*4)+7 > call2()' might take longer,
as the entire tree of the expression has to be traversed.

Design Considerations

It would also be possible to infer the types of entire functions.
This is not implemented in smalldragon, as it would be much more difficult to implement.
Unrelated to the implementation difficulty and compile-time cost,
the function signature is a good source of documentation.