anything like C++ references?
Mark 'Kamikaze' Hughes
kamikaze at kuoi.asui.uidaho.edu
Tue Jul 15 12:19:18 CEST 2003
Tue, 15 Jul 2003 03:16:08 +0100, Stephen Horne <intentionally at blank.co.uk>:
> On 14 Jul 2003 23:31:56 GMT, kamikaze at kuoi.asui.uidaho.edu (Mark
> 'Kamikaze' Hughes) wrote:
>> It looks like you've almost reached understanding, though you've been
>>given a bad start with a very idiosyncratic and monolingual
>>understanding of what "computer science" teaches--that was certainly not
>>in the classes I took, but apparently yours were different.
> Really. My computer science lessons were taught in a way that
> respected the source of most of the theory in mathematics -
> algorithms, Church's lambda calculus and that kind of stuff.
> What did your lessons teach?
How computer programming actually works, how to make interpreted and
compiled languages, how to use them to solve problems, how to analyze
algorithms, etc.... The usual. Among those were classes in languages
other than C, which is very broadening, and I highly recommend that to
you. History lessons and maths are fine for liberal arts and science
credits, but they're not computer science. As for respect, I respect
working code. Theory without working code isn't just useless, it's an
actively harmful delusion.
>> Since every operation in Python operates on pointers, there's no use
>>in having a special syntax for it. You don't need all the * and & and
>>-> line noise.
> The point of the thread is not pointers - they are a side issue.
Not so. They are the central, the *only* issue, you just don't
realize it. Python just does not have what you think of as "assignment"
or "variables". It only has pointers. If you understand and accept
that, you'll be able to use Python successfully. If you persist in
elevating inappropriately-applied theory above reality, you will fail.
> When you use variables, you are using a concept from mathematics. In
> mathematics, variables bind to values. All values are immutable.
That's very nice. Python is not mathematics. It's a programming
language. While there are some mathematical foundations to CS, it's
primarily an engineering discipline with its own terms and entirely
> Python binds variables to objects, not values. For immutable objects
> this is an unimportant implementation detail. For mutable objects, it
> breaks the mathematical principle of variables being bound to values.
Yes, it sure does. But would you look at that, my Python code still
seems to work just fine. Guess it just doesn't know it's violating
important mathematical principles.
i=i+1 is just as much a mathematical heresy, but it doesn't matter,
That's because PYTHON IS NOT MATHEMATICS.
>> Stop trying to make Python into C/C++, and you'll be happier with it.
>>Or stop using Python, if you really don't like the design philosophy.
>>There are plenty of Algol-derived languages out there. PHP and
>>especially Perl are more C-like in their internal logic, and you might
>>find them more pleasant.
> This is bogus.
> I don't want Python to become C or C++. I want Python to respect
> principles that come from mathematics and computer science. Not for
> reasons of theory pedanticism, but because the current system can and
> does regularly cause confusion and errors.
On the contrary, implementing the design you suggest causes confusion
and errors; we see that all the time with C newbies, confronted with
variables that may be on the stack, on the heap, or pointers to
variables that could be anywhere. Python is internally consistent, and
this behavior only has to be explained once to be fully grasped with all
of its implications. I have taught several previously-non-programmers
to use Python, and how names and objects worked was never once an issue
after the first lesson. The only people who have problems with it, IME,
are those who are willfully ignorant, or who just skimmed a tutorial and
some example code rather than learning the language properly.
Since Python has the same behavior as most of the Lisp-philosophy
languages, rather than the Algol-philosophy ones like C, yes, you do
want Python to become something it's not.
> The fact that Python claims to be a very high level language, and yet
> you have to worry about the binding of variables to objects -
> something that should be a low level implementation detail - has very
> real everyday implications.
This is a meaningless statement. What are those "very real everyday
implications"? Python works just fine, and the "everything is an
object, and names just point to objects" paradigm is vastly easier to
explain to newbies than your soi-disant mathematical paradigm.
> Respect the idea of variables binding to values and suddenly the need
> for pointers becomes more obvious. You cannot abuse mutable objects to
> fake pointer functionality (another everyday fact of Python
> programming) if the binding of variables to values (rather than just
> objects) is respected.
If you're trying to say that the trick I showed you of modifying a
list to reproduce the effect of reference arguments is not possible in,
say, C, you're wrong. Trivially proven wrong, even, since Python is
implemented in C. In fact, the only languages where that won't work are
those which don't allow passing complex arguments at all; some
pure-functional toy languages, perhaps.
If you're seriously demanding that all languages adhere to a religious
observance of object and variable purity that exists in no serious
programming language, you might want to stop and consider *why* nobody
Eh, enough. You've been shown how Python really works, and why.
Anything else is quite futile. If you want Python to change to obey
your ideals, well, you're unlikely to effect that change; pigs will fly
and politicians will tell the truth first. You are the only change that
can and must happen here, if only to a different and more suitable
language. Perhaps you should write your own language, if no others are
acceptable to you.
<a href="http://kuoi.asui.uidaho.edu/~kamikaze/"> Mark Hughes </a>
"The computer is incredibly fast, accurate, and stupid.
Man is unbelievably slow, inaccurate, and brilliant.
The marriage of the two is a force beyond calculation." -Leo Cherne
More information about the Python-list