Building CPython

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat May 16 14:18:41 EDT 2015


On Sat, 16 May 2015 11:59 pm, Marko Rauhamaa wrote:

> Steven D'Aprano <steve+comp.lang.python at pearwood.info>:
> 
>> A couple more negatives:
>>
>> - no such thing as inheritance;
> 
> Untrue. My simple Scheme object system (125 lines incl. documentation)

Ah yes, I've seen Javascript code like that too. Each line is thirty
thousand characters long...

*wink*


> supports multiple inheritance without classes. Maybe I should port that
> to Python...

I'd like to see it, but somehow I don't think that your "Scheme object
system" is another name for "closures". We were talking about closures,
weren't we?

It sounds like you have implemented a form of prototype-based object
programming. The question of whether prototype-OOP has inheritance is an
interesting one. Clearly prototypes implement something *like* inheritance,
but it is based in delegation or copying. Delegation-based cloning is quite
close to class-based inheritance, but copying-based cloning is not.

My sense is that I prefer to say that prototypes don't have inheritance in
the same sense as classes, but they have something that plays the same role
as inheritance. But if you want to call it inheritance, I can't really
argue.



>> - "is-a" relationship tests don't work;
> 
> From the ducktyping point of view, that is an advantage. The whole
> Linnaean categorization of objects is unnecessary ontological chaff. How
> many times have people here had to advise newcomers not to inspect type
> and instance relations of objects and just call the method?

Um, is that a trick question? I don't remember the last time.



>> - an unfamiliar idiom for most people;
> 
> That's impossible to ascertain objectively. Java and JavaScript
> programmers (of all people!) routinely deal with closures.

I don't think so. I can't say for Javascript, but for Java, there's a lot of
confusion around closures, they've been described as "evil" with the
recommendation not to use them, and people cannot even agree when they were
introduced!

http://java.dzone.com/articles/whats-wrong-java-8-currying-vs
www.javaworld.com/javaworld/jw-06-2008/jw-06-closures.html


I mean, people had to *debate* the introduction of closures? There were
three competing proposals for them, plus an argument for "don't add them".
Some people say closures were added in Java 7, others say closures have
been there since the beginning, and James Gosling himself says that Java
used inner classes instead of closures but the result was painful...

It seems to me that in the Java community, there's a lot of confusion over
closures, which are seen as an advanced (and rather scary) feature. Hardly
routine.


-- 
Steven




More information about the Python-list mailing list