On 25/03/2010 16:00, Kerry, Richard wrote:
I know that variables are constants in XSL
well better to say variables hold values (as they do in mathematics)
rather then hold references to values (as they do in imperative
programming languages)
I still think that variables are misnamed in XSL
the terminology matches all uses that I'm aware of including mathematics
and fairly old computer languages such as lisp and newer functional
languages such as ML, haskell, F#, etc.
When I was first shown programming (fortran and algol) in the 70's
a big deal was made that "variable" in those languages was a strange
computer-related thing that didn't mean what you would expect it to mean
and that x=x+1 was ok despite the fact that it was clearly nonsense in
mathematics. A few decades later and there seem to be people so exposed
to this usage that they have convinced themselves that it is somehow
natural:-)
> as they aren't (variable that is).
They're as variable as they are in C, it's just that in C a variable
declared as int (say) is associated (abstractly) to a pointer to an
integer and you can change the value of the integer pointed to while
still being the "same variable" (that is, the variable holds the same
pointer) but in functional languages when you bind an integer to a
variable the variable holds the integer itself (conceptually: an
implementation may well use c or java variables in the background)
so while you can bind another integer to a variable of the same name
it's a completely new variable in that case, unrelated to the first.
I'd never heard the term "variable" used until I started programming computers, and
I remaind slightly suspicious of the implication that they have a
meaning in mathematics. I thought they were called "values" there.
you were never asked to solve the equation x*x = 4, for the variable x
?? In the above 4 is a value and x is a variable or an unknown.
In functional languages, as in life, if you have a "function of one
variable" then within the body of that function, the variable will have
the same value: a function returns a result, it never[1] causes its
input to mutate. the "variable" terminology refers to the fact that you
can call the function multiple times with the input value varying.
In imperative languages this is not the case, f(x) may change x, which
makes lots of things counter-intuitive and makes lots of "obvious"
optimisations incorrect. as for example f(x) + f(x) can't be simplified
to 2*f(x) as the value of x may have changed after the first call to f.
Uncertainly,
Richard.
#
David
[1] never say never: real computer languages may make this statement
slightly false, but never let details spoil a dogmatic argument;-)
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________