StardustPL / Stardust

"A programming language that doesn't make me angry to use it."
https://StardustPL.GitHub.IO/
The Unlicense
4 stars 0 forks source link

Planning: ADL and FDL #17

Open LB-- opened 9 years ago

LB-- commented 9 years ago

Argument-Dependent Lookup and Function-Dependent Lookup will both be used when calling functions. ADL happens first. See #13 for order of scope lookup. Unresolved parameters/identifiers are ignored at this point.

After ADL comes FDL - one or more functions have been selected and the selection needs to be narrowed down to just one. First, unresolved parameters/identifiers are attempted to be resolved based on the functions' own local scopes. Only the functions which resolve all parameters/identifiers in the expression are considered.

After FDL resolves parameters/identifiers, traditional type-based lookup should narrow down to one function as with many other languages that allow function overloading.

Resolving parameters/identifiers? Huh?

Functions have privacy and scoping rules too - any publicly exposed members of the function can be considered during FDL, such as enums and types specific to that function. This allows for unqualified names, or names qualified as belonging to the function, to be used in a function call expression and for those names to bind to those within the function's scope.

With f(0, yes), if yes is unresolved for ADL, then ADL will only use 0 to gather functions. Then, FLD will loom for functions that expose yes. If yes would normally be resolved when it should not be, then f(0, f:yes) may be used instead to have it participate in FDL. If each f needs to be different, rather than the same, then yet-to-be-determined function selection syntax can disambiguate this.

LB-- commented 8 years ago

There should be some way to request ADL/FDL dispatch on some types and to then store the resulting function for later use.