I should be able to use Functions in a natural OO way
Summary: See the Other Details, but the high concept is that I should be able to use Functions as Methods properly, including overriding them in sub-Models.
Currently, to use a Function that is defined on a Thing (as opposed to simply _apply'd), the syntax is very awkward: you have to explicitly say something like:
... stuff -> My Thing.My Function() ->
It would be far more natural to pick up My Function based on where it is declared. That is, if this QL code is declared on a Model, and that Model has My Function as a Method, it should simply use the local My Function. That's kind of a no-brainer from an OO POV. Moreover, if the Method is overridden in a sub-Model, the overridden version should be used. (Which can't even be worked around easily in the current situation.)
The problem is that there are really three evaluation contexts we should be checking when resolving a QL name:
- The received context;
- The defining context (the left-hand side of the dot, if any); and
- The lexical context, where this QL is declared.
Only the first one works consistently; the second works in some circumstances but not all, and the third isn't checked at all. The third is the one we want here.
In principle, this isn't insanely hard, but it's a non-trivial change to the QL processor, and may wind up breaking some stuff here and there. So it needs to be done with care, but should probably happen sooner rather than later.