[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tads3] 'inherited' and propNotDefined



Does anyone see a problem with changing the way 'inherited' is processed so that propNotDefined is fired if there is no inherited definition of the method?

One situation where it's especially problematic not to have this is when you're using 'modify' to add an override to a proxy-style object that uses propNotDefined to delegate to an underlying implementation object. The 'modify' override has no clean way to inherit the original pre-modified handling except to do the delegation explicitly, which isn't very clean and would break if the underlying pre-modified class ever added the method being overridden.

class Proxy: object
proxyBase = nil
propNotDefined(prop, [args]) { return proxyBase.(prop)(args...); }
;
modify Proxy
abc(x) { return inherited(x); } // doesn't work: there's nothing to inherit
xyz(x) { return proxyBase.xyz(x); } // works, but breaks if we add xyz() to Proxy
;

I suppose that the way to do this without any chance of breaking existing code would be to add a new method, call it inhNotDefined() or propNotInherited().

propNotInherited(prop, [args]) { return proxyBase.(prop)(args...); }

But I'm not sure this is necessary. I doubt that using propNotDefined() would cause any problem for existing code, since the only code affected would be methods that inherit() off into empty space in objects that also have propNotDefined() defined. If a separate method isn't necessary for compatibility or other reasons, it would probably be better to fold this into propNotDefined to cut down on the amount of code needed to use this mechanism.

One more detail: I think that the propNotDefined (or propNotInherited or whatever) to be invoked would have to be found using the same rules that we use to use to try to find the inherited method that turns out not to exist. Consider:

class A: object
propNotInherited(prop, [args]) //...
;
class B: A
propNotInherited(prop, [args]) //...
xyz(x) { return inherited(x); }
;

When we call B.xyz(), I think we'll want to invoke A.propNotInherited(), NOT B.propNotInherited(), because the search for the inherited xyz() would start with A, not with B.

Any thoughts about this? Does anyone see any model-consistency or practical problems with it that I'm missing? Should propNotDefined() be re-used, or is a new method preferable?

--Mike

_________________________________________________________________
Fast, faster, fastest: Upgrade to Cable or DSL today! https://broadband.msn.com