[Python-Dev] PEP 246: lossless and stateless
Clark C. Evans
cce at clarkevans.com
Fri Jan 14 03:02:54 CET 2005
On Thu, Jan 13, 2005 at 08:08:43PM -0500, Bob Ippolito wrote:
| >Ok. I think we have identified two sorts of restrictions on the
| >sorts of adaptations one may want to have:
| >
| > `stateless' the adaptation may only provide a result which
| > does not maintain its own state
| >
| > `lossless' the adaptation preserves all information available
| > in the original object, it may not discard state
| >
| >If we determined that these were the 'big-ones', we could possibly
| >allow for the signature of the adapt request to be parameterized with
| >these two designations, with the default to accept any sort of adapter:
| >
| > adapt(object, protocol, alternative = None,
| > stateless = False, lossless = False)
| >
| >Then, Guido's 'Optional Static Typing',
| >
| > def f(X: Y):
| > pass
| >
| > would be equivalent to
| >
| > def f(X):
| > X = adapt(X,Y, stateless = True, lossless = True)
..
|
| In some cases, such as when you plan to consume the whole thing in one
| function call, you wouldn't care so much if it's stateless.
etrepum,
True False
stateless adapter may not add adapter may have its
state beyond that already own state, if it wishes
provided by the object but additional state is
not required
lossless adapter must preserve and adapter may discard
give all information which information if it wishes
the underlying object has
So, in this case, if your consumer doesn't care if the adapter is
stateless or not, just call adapt(), which defaults to the case
that you wish.
Is this a better explanation? Or is this whole idea too convoluted?
Best,
Clark
More information about the Python-Dev
mailing list