Prototype OO

bruno.desthuilliers at gmail.com bruno.desthuilliers at gmail.com
Wed Apr 2 14:24:34 EDT 2008


On 2 avr, 16:52, sam <s... at mas.pl> wrote:
> Bruno Desthuilliers napisał(a):
>
> > Don't misunderstand me : I'm not saying that class-based is better (or
> > worse) than prototype, I'm not saying that Python is perfect, I'm not
> > saying that your points are not worth any consideration, I'm just saying
> > that, from your arguments, I have the very strong impression that you
> > don't know enough about Python's object model to understand it's
> > coherence and strength (and I've probably expressed it a rather harsh
> > way - please bear with me). If I'm wrong, please say so, pardon me and
> > we'll move ahead.
>
> I understand you. Thanks for spending time to write all that things.
>
> The point is that when I say:
>
>         -- you should have same syntax of lambdas and ordinary functions
>
> then Python gurus say:
>
>         -- lambda is very good and is so special, that has its own syntax
>
> But it seems to me, that lambda syntax was introduced because of interpreter
> limitations -- indentation and expressions. So it is not perfect, but must be as
> it is now.

You're of course right on this.

OTHO, I found out that with languages that let you define "full-blown"
inline anonymous functions (like javascript), I tend to make any non-
trivial function into an ordinary named one - mainly for readability.
So, while I often use Python's lambdas, the imposed limitations is ok
to me since I wouldn't use it for anything more complex. But I may be
a bit biased here since I discovered the concept of anonymous
functions (and quite a lot of other more or less functional
programming inspired stuff) with Python.

Also - as a side note - while the syntax is a bit different, the
resulting object is an ordinary function.

> Then I say:
>
>         -- __id is awful, because it is a trick to prefix names
>
> and gurus say:
>
>         -- it is good solution for name conflicts
>
> But somebody may prefix his names with class names and cause nameconflict,

Here the problem is more philosophical than anything else. Python's
philosophy is that most programmers are responsible and normally
intelligent, so treating them all like retarted dummies because
someone might one day do something stupid is just wasting everyone's
time. This is also why there's no language-enforced access
restriction, only a simple stupid convention to denote implementation
stuff from API. The fact is that it JustWork.

> so
> maybe it is not so good?

It's enough. FWIW, I'm not sure I had a use-case for this feature more
than a couple time in 7+ years.

>  I would prefer to hear something like "other solutions
> were very complex, and our zen says 'Simple is better than complex.', so we
> decided to use this simple and not perfect solution"

Simple, indeed. But why "not perfect" ? What else would you want ?



More information about the Python-list mailing list