help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: origin of the index syntax


From: Ted Harding
Subject: Re: origin of the index syntax
Date: Mon, 27 Jun 2005 14:57:24 +0100 (BST)

On 27-Jun-05 Bill Denney wrote:
> On Mon, 27 Jun 2005, David Bateman wrote:
> 
>> Francesco Potorti` wrote:
>>
>>> Dear Octave users,
>>> 
>>> does anyone know where the index expression syntax used
>>> in Octave comes from?  Is the Matlab people who invented it?
>>> Or else it is older?
>>> Was it just the evolution of something in common usage?
>>> 
>> I believe the syntax was developed at the time when octave-forge
>> was being setup, and its category index was also being setup.
>> Probably Paul Kienzle had a hand in the development, however the
>> original author of the make_index script, that makes use of the
>> INDEX files to create the category index, is Albert Danial. So if
>> there is someone to praise (blame :-) ) for the INDEX file syntax
>> it is  probably him.
> 
> I'm not sure, but I think that Francesco is referring to the
> index like a(5).  I don't have an answer, but I think that's
> the quesiton.

I suspect it is too, but Francesco can confirm!

Such things go back almost to the origins of the Universe.

Some languages distinguish between a function call like fname(...)
and reference to an indexed variable like vname[...] by different
syntax. C is such a language, and originated in 1972 (though it
evolved from languages going back to the early 60s).

Other languages use the same, e.g. fname(...) and vname(...), for
both, usually relying on the distinction being stated in the
declaration of the variable or function. Fortran is such a language,
and so are Octave and Matlab (though using a quite different mechanism
to identify types). Fortran goes back to 1957! (And the "Backus Normal
Form" used in formal specification of a computer language is named
after John Backus, one of the co-creators of the original Fortran).

The original Matlab goes back to the late 70s, and was slightly
different from the Matlab that came out as commercial software in
1984 (as I recall, there was different syntax for multiplication
of numbers to multiplication of matrices, for instance). It used
to be possible to get hold of the C code for the original Matlab
on the web, and I can remember compiling this on Linux around
1992 and having it work (more or less). I don't know if it's still
possible to find it.

Octave itself began to be developed in 1988, and emerged in 1993-4.
It seems it was deliberately designed to emulate the commercial
version of Matlab. See the paper "Octave: Past, Present, and Future"
by John Eaton, 2001:

http://jbrwww.che.wisc.edu/jbr-group/tech-reports/twmcc-2001-03.pdf

  "We eventually decided to implement something that would
   be mostly Matlab-compatible so that our colleagues could
   switch to using Octave without having to learn a completely
   new language."

However, the distinction between "[...]" and "(...)" being
discussed is a syntactic matter, or a matter of implementation,
and not a semantic one, of course.

An array is really only a special kind of function, being a
mapping from X to Y where the domain X consists of values
expressible as (i,j,k,...) and the domain Y consists of, say,
numbers or characters, such that there is a unique y in Y for
any x in X.

So it would make perfect semantic sense to use "functional"
notation, i.e. f(...), for both (as Fortran and Octave do).

The syntactic distinction can be useful at the level of computer
implementation, since there are special mechanisms for evaluating
the value of and array element, and the distinction can be made
when name[...] is parsed differently from name(...). This
implementation distinction reflects the fact that, as a rule, once
an array has been defined and given values, evaluating an array
element is simply a matter of looking it up in the "table" which
is the internally stored array.

On the other hand, evaluating the value y of a function for a
particular value of x is usually a matter of starting from
the value of x, and applying some numerical algorithm to compute
the value of y (it being unusual, though possible, for the
pairs (x,y) to be explicitly stored, once and for all, like an
array).

Ah well, interesting question!

Best wishes to all,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 27-Jun-05                                       Time: 14:57:16
------------------------------ XFMail ------------------------------



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]