Zope 3.0, and why I won't use it

Josiah Carlson jcarlson at uci.edu
Mon Nov 15 20:50:12 EST 2004


aleaxit at yahoo.com (Alex Martelli) wrote:
> 
> Jim Fulton <jim at zope.com> wrote:
> 
> > >   Guido has repeatedly stated that a future version of Python will
> include static type support.  The Zope project has driven numerous past
> changes to Python.  What's funny about this?
> > 
> > For the record, I'm against static typing for Python, although,
> > if Guido decides he wants it, I have an open mind. :)
> 
> Glad to hear that.  As for me, I'd love it if function arguments, only,
> could bear an 'as' clause (making 'as' a keyword is long overdue):
> 
> def x(y as foo, z as bar):
>     <body of x>
> 
> translating into:
> 
> def x(y, z):
>     y = adapt(y, foo)
>     z = adapt(z, bar):
>     <body of x>
> 
> where builtin 'adapt' does protocol adaptation.  On the other hand, if
> the semantics of those 'as' clauses were something like:
> 
> def x(y, z):
>     if type(y) is not foo: raise TypeError, 'y must be foo'
>     if type(z) is not bar: raise TypeError, 'z must be bar'
>     <body of x>
> 
> then that's the day I move to Ruby, or any other language that remained
> halfway sensible (if any).
> 
> In other words, if the 'as' clause (or whatever absurd syntax ends up
> being adopted in its place -- judging on recent performance, probably a
> two-arguments version of splat, or a nice << to complement the just as
> nice 'print>>bah,humbug' syntax -- good thing I don't really care about
> syntax sugar;-) ends up being a way to ease *type-checking*, then, well,
> I'll evaluate that as being on a par with easing alcohol abuse.  What
> the syntax supports, people will do more of, and we already know that
> type-checking, like alcohol abuse, is a _very_ popular although
> self-destructive practice.
> 
> Protocol adaptation is the polar opposite from type checking.  I'd see
> syntax that supports adaptation as being on a par with easing things
> that are good for you, as well as pleasant, and yet are not widely
> practiced -- yoga, aerobics, many other forms of exercise, healthy
> nutrition -- the language gently encouraging you to do the right thing.

Decorators to the rescue?

def d_adapt(t):
    def f(a):
        return adapt(a, t)
    return f

def d_adaptors(*adaptors):
    #some work necessary to make kwargs work
    def f(fcn):
        def f(*args):
            return fcn(*[i(j) for i,j in zip(adaptors, args)])
        return f
    return f

@d_adaptors(d_adapt(foo), d_adapt(bar))
def x(y, z):
    <body of x>


 - Josiah




More information about the Python-list mailing list