[Python-Dev] PEP 246: lossless and stateless

Just van Rossum just at letterror.com
Fri Jan 14 17:27:53 CET 2005


Phillip J. Eby wrote:

> At 10:09 AM 1/14/05 +0100, Just van Rossum wrote:
> >Guido van Rossum wrote:
> >
> > > Are there real-life uses of stateful adapters that would be
> > > thrown out by this requirement?
> >
> >Here are two interfaces we're using in a project:
> >
> >   http://just.letterror.com/ltrwiki/PenProtocol (aka "SegmentPen")
> >   http://just.letterror.com/ltrwiki/PointPen
> >
> >They're both abstractions for drawing glyphs (characters from a
> >font). Sometimes the former is more practical and sometimes the
> >latter. We really need both interfaces. Yet they can't be adapted
> >without keeping some state in the adapter.
> 
> Maybe I'm missing something, but for those interfaces, isn't it okay
> to keep the state in the *adapted* object here?  In other words, if
> PointPen just added some private attributes to store the extra data?
> 
> 
> >Implicit adaptations may be dangerous here, but I'm not so sure I
> >care. In my particular use case, it will be very rare that people
> >want to do
> >
> >     funcTakingPointPen(segmentPen)
> >     otherFuncTakingPointPen(segmentPen)
> 
> But if the extra state were stored on the segmentPen rather than the
> adapter, this would work correctly, wouldn't it?  Whereas with it
> stored in an adapter, it wouldn't.

Are you saying the adapter could just hijack some attrs on the adapted
object? Or ore you saying the adapted object should be aware of the
adapter? Both don't sound right, so I hope I'm misunderstanding...

Just


More information about the Python-Dev mailing list