Variables

Kay Schluehr kay.schluehr at gmx.net
Sun Apr 24 02:11:38 EDT 2005


Richard Blackwood wrote:

> Could I honestly argue this to him? From what basis do I argue that
it
> is not an equation? In any event, he would likely (passionately)
> disagree considering his notion that programming is an off-shoot of
math
> and thus at the fundamental level has identical concepts and rules.

What is special on *equations* in mathematics is that both sides of an
equation are ususually not equal! Identifying an equational expression
"x=1" with the solutionset {1} of the equation is for convenience. For
more complex equational expressions, say "x**5+4x-1 = 0" You never
confuse the equation with the solution set. The solution set is nothing
but a set of values that if inserted into the equation would really
create equal terms on both sides i.e. "0=0" in our example.

To make a difference between an assignment and an equation it would be
better to use a different operator for an equation, say "==". Usually
"==" is interpreted in programming languages as a binary operator that
returns a boolean value. This is a usefull but narrow perspective that
is broken by many computer algebra systems like Mathematica that adapts
"==" to the the more general equational interpretation.

The interpretation of "x = 5" as defining a "constant" may stem from
languages ( Visual Basic ? ) that introduce a "var" keyword to make
variable creation explicit.

  var x = 7;

or

  var int x = 8;

In C You refuse "var" and restrict "immutable variables" i.e. constants
by means of the keyword "const".

In Python You can't define a "constant" by simply assign a value to
name. You can interpret assignment as creation of a variable of domain
object. Since each expression is an object You can drop "object" from
C-like definitions

  object x = 8

and reduce it to

  x = 8

To become more precise You have to do workarounds.

Ciao,
Kay




More information about the Python-list mailing list