MethodsΒΆ

All methods in Minilang are multimethods, that is they use the runtime types of all arguments to determine which function to call.

Methods are written as :name (or :"name" if name contains non-alphanumeric characters). Methods also act as atoms or symbols, two methods with the same name are identically equal. Infix operators such as +, *, etc, are equivalent to methods with the same name (:"+", :"*", etc).

If no suitable method is found for a specific combination of arguments, an error is raised. Methods can be defined using the meth keyword:

1print('5 * \"word\" = {5 * "word"}\n')
MethodError: no method found for *(int32, string)
   <console>:1
1meth *(Count: integer, String: string) sum(1 .. Count;) String
2
3print('5 * \"word\" = {5 * "word"}\n')
5 * "word" = wordwordwordwordword