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

Stefan Schwarzer s.schwarzer at ndh.net
Mon Jan 7 14:36:09 EST 2002


Hi Alex

Alex Martelli 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
> loops, it may be a crucial saving of resources to be able to generate
> the items one by one, each only as needed, rather than having to
> build the whole list in memory at the same time.

hm, rather flexible :-)

> But I don't see how these consideration apply to Haskell-ish typeclasses
> (which are not offered in C++, anyway).  Isn't their superiority over C++'s
> "abstract classes" rather obvious?  And what diminution of simplicity do
> you see in Haskell typeclasses when compared to C++ abstract classes?

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 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.

Stefan



More information about the Python-list mailing list