Waldek Hebisch wrote:
Frank Heckenbach wrote:
I just realize one issue with user-defined operators that might not have been discussed here yet, shadowing.
If an operator is defined in outer and inner scopes, say with different enough argument types, is the outer one still accessible in the inner scope (i.e., the inner one overloads the outer one) (a), or not accessible (i.e., shadows) (b)?
Well I am tempted to forbid definitions in inner scopes. Why ? One can treat object method call as a "generic" function. When calling method the actual function is chosen based on the type of the object. If you allow objects in inner scopes similar difficulties appear. I would like overloading to be like method dispatch, so it is natural to share the restriction.
Of course, for objects there are other issues involved (you can't store pointers to local routines in static tables -- BP can't do it at all, GPC would have to rebuild the tables on each entrance of the outer routine), which don't apply to operator dispatch. (The fundamental difference is that operator dispatch is always compile-time, AIUI, where virtual method dispatch can be runtime.)
Of course, one question is, do other dialects allow operator (and function) overloading in inner scopes? If none do, I wouldn't insist on it, but if some do, we have compatibility concerns ...
Frank