On Thu, Jan 13, 2005 at 11:50:37PM -0500, Phillip J. Eby wrote: | 'lossless' isn't really a good term for non-noisy. The key is that a | "noisy" adapter is one that alters the precision of the information it | provides, by either claiming greater precision than is actually present, | or by losing precision that was present in the meaning of the data.
Noisy doesn't cut it -- my PC fan is noisy. In computer science, noisy usually refers to a flag on an object that tells it to spew debug output...
Come up with a better name, then. Precision-munging? :)
| Anyway, for type declaration, IMO statelessness is the key criterion. | Type declaration "wants" to have true adapters (which can maintain object | identity), not decorators (which are distinct objects from the things | they add functionality to).
Stateful adapters are very useful, and the value of PEP 246 is significantly reduced without alowing them.
Absolutely. But that doesn't mean type declarations are the right choice for PEP 246. Look at this code:
def foo(self, bar:Baz): bar.whack(self) self.spam.fling(bar)
Does this code produce transitive adaptation (i.e. adapt an adapter)? Can't tell? Me neither. :) It depends on what type spam.fling() declares its parameter to be, and whether the caller of foo() passed in an object that needed an adapter to Baz.
The problem here is that *all* of the arguments you and Alex and others raised in the last few days against unconstrained transitive adaptation apply in spades to type declarations. My argument was that if well-designed and properly used, transitivity could be quite safe, but even I agreed that uncontrolled semi-random adapter composition was madness.
Unfortunately, having type declarations do adapt() introduces the potential for precisely this sort of uncontrolled semi-random adapter madness in seemingly harmless code.
Now compare to *this* code:
def foo(self, bar): adapt(bar,Baz).whack(self) self.spam.fling(bar)
It's obvious that the above does not introduce a transitive adaptation; at least if it was passed an "original" object, then it will pass on that original object to spam.fling().
So, explicit use of PEP 246 doesn't introduce this problem, but type declarations do. With type declarations you can never even *know* if you have the "original object" or not, let alone get it if you don't have it.
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com