class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes)

Alex Martelli aleaxit at yahoo.com
Mon Jan 7 16:40:51 EST 2002


Stefan Schwarzer wrote:
        ...
> ["substitute" for non-existing __list__]
>> Define __iter__ instead: that's what list(x) calls, as well as any
>> "for item in x" loops.  It makes no difference for list(), but, for
        ...
> hm, rather flexible :-)

Yep, iterators are.


> I didn't want to compare Haskell with C++. Indeed, I know nothing about
> Haskell. It might have been an unconscious reflex to "compare" them
> because of the association by doing things implicitly. Since I do know
> practically nothing about Haskell, I clearly can't judge about it. :-)

The only substantial "thing done implicitly" (optionally) in Haskell (and 
not in C++) is that types can be inferred by the compiler on your behalf -- 
you don't have to declare them, although you may (it's probably more 
idiomatic Haskell to declare them anyway).


> The interaction of the method-for-one and the method-for-many though is
> really interesting because the two are often (or often enough to trigger
> a feeling of familarity) needed both.

I agree, and that's why I like to use this as a toy example of a typeclass 
rather than the probably more canonical ones using arithmetic.


Alex




More information about the Python-list mailing list