anything like C++ references?
Stephen Horne
intentionally at blank.co.uk
Tue Jul 15 02:11:22 CEST 2003
On 14 Jul 2003 06:02:54 -0000, Moshe Zadka <m at moshez.org> wrote:
>On Sun, 13 Jul 2003, Stephen Horne <intentionally at blank.co.uk> wrote:
>
>> The problem is that you are confusing implementation with semantics.
>> The meanings of 'variable', 'value', 'assignment' etc are defined by
>> computer science.
>
>This is not just wrong, but as far as it is right, the semantics agree
>with Python's :)
>In computer science, the theoretical model one first learns is a turing
>machine. Turing machines have no variables or values, merely tapes. While
>I'm sure you can creatively translate the terms to turing machiens, this
>exercise seems fairly pointless. Ram machines are similar. More abstract
>models, like recursive functions, deal with integers only, so again you
>would need hard to associate terms with them [you can implement a list
>of integers with the p_1^n_1*....p_k^n_k, where p_1,...,p_k are distinct
>primes. I'm not completely sure how this would translate to Python, though :)]
Ever seen Euclids algorithm for the highest common factor?
Euclid was around somewhat before turing. Algorithms are a
mathematical concept. When you solve a quadratic equation by
completing the square, you are applying an algorithm for instance.
In maths, variables bind to values. Not to intermediate things that
implement or represent values. How Python implements its binding of
variables to values is its own business, but IMO if it merely binds
variables to objects - and does not correctly implement binding to
values using that mechanism - then it is behaving in a confusing and
error-prone way.
>However, computer science did have a minor notational revolution: Lisp.
>Lisp was originally invented as an abstract way to express computations
>in a more natural, and yet well-defined, way. The fact that lisp can be
>*implemented* was somewhat of a shock, but it turned to be a fairly useful
>language.
Funny. From what I recall of Churches lambda calculus, variables bind
to values. Changing the value bound to one variable does not change
the value bound to any other variable. After all, why would Church
worry about the details of implementation on a computer? He was a
mathematician. His ideas were developed in the 1930s, IIRC - they
weren't applied on computers until much later.
Lisp was created as a way of implementing Churches lambda calculus. In
doing so, some compromises were made due to the state of technology at
the time.
>[Note that in Lisp conses, for example, are actually mutable. However,
>many functions treat them as immutable objects. This is perfectly fine,
>and was a concious design decision in Lisp. Similarily, Python wouldn't
>*need* tuples: they can be implemented as lists. The immutability allows
>the implementation to play tricks with memory usage, though.]
No - mutability allows the implementation to play tricks with memory
usage. With immutables, Python binding of variables to objects
correctly implements binding of variables to values.
More information about the Python-list
mailing list