A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-January/051035.html below:

[Python-Dev] PEP 246: lossless and stateless

[Python-Dev] PEP 246: lossless and statelessPhillip J. Eby pje at telecommunity.com
Fri Jan 14 06:28:07 CET 2005
At 12:00 AM 1/14/05 -0500, Clark C. Evans wrote:
>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.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4