A large part of the function template system is implemented. However, a lot of fonctionalities are missing, and template types (parametric types) are not in yet, with the exception of function types, which can contain template expressions.
Templates are designed to look mostly like regular function declarations, except with named placeholders replacing either types, names, or inside type expressions.
Template variables are not declared separately, as is usually the case, because the author has been traumatized by the verbosity of c++ templates. In addition, there is no separate template argument list, they are all intermixed among normal parameters.
Example of a template function that infers a type parameter T from a parameter:
void templateFunc( $T a ) {}
Example of a function that take an explicit type template parameter and a parameter of that type:
void lomarf( type $T, $T a )
Example of a function that takes a non-type template parameter:
void lomarf( int $I )
Note that a non type template parameter and a type parameter are the same, since types are compilation time values.
To specialize a template, replace a parameter with a constant:
void lomarf( int, int a )
Since overloading resolution favor exact matches over generic ones, calling lomarf( int, 123 ) will call the above and not "void lomarf( type $T, $T a )"
Note that you can have specializations without having a general case.
For instance:
void laffo( int ) {}
void laffo( bool ) {}
Can perfectly exist even if there's no generic void laffo( type $T ) {}
overload.
C++ have two similar but not exactly identical pattern matching systems: overloading and template specializations, both of which have slightly different capabilities. You often have to wrap functions as a static method in a template struct with partial specialization to get them to be called on the subset of types that you want, which is awkward.
In goose, the goal is to have overloading resolution cover the features of both. Even specialization of parametric types (ie template class specialization) will be a case of overload resolution of type constructors.
In the future, it is envisioned to be able to have compilation time predicates to implement a feature similar to C++ concepts:
void foo( copyable $T a ) {}