Open LB-- opened 9 years ago
For calling functions, there should be a syntax for explicitly specifying the names of parameters so as to pass parameters in any order. Additionally, this will allow skipping over consecutive optional parameters.
There should be some way to support type deduction as with C++ template functions. The syntax should allow for calling the function and either explicitly specifying the type parameters or implicitly allowing the compiler to deduce the type parameters.
Type deduction: a solution has been staring me in the face for months.
(function-name, deduced-typename-1, deduced-typename-2; deduced-typename-1 argument-1, deduced-typename-2 argument-2)
With optional ability to manually specify a deduced parameter when calling the function.
A function is a special kind of namespace encapsulating related named callable objects. If the arguments and usage of a function call are not ambiguous, the name of the callable object does not need to be specified. Function overloading is equivalent to having multiple named callable objects in the function's scope. There are no restrictions on function overloading as long as the callable objects have distinct names.
Functions can also be considered a map from an ordered list of types to one or more named callable objects. A C++ pseudo-representation might be
map<vector<Type>, map<string, Callable>>
Functions can also be manually implemented so that the mapping of types to named callable objects is handled by interactive code, thus (for example) allowing for functionality similar to C++'s template type deduction from provided parameters.