Maxima: Syntax improvements



Costa,

Thanks for the suggestions.

> (1) Its a very good idea to incorporate Matlab syntax for matrix manipulations eg. a(1:4,[1 5 6]).

I assume that this denotes an array slice, which would certainly be
useful functionality for Maxima.  Robert Dodier's amatrix does
something like this (see
http://maxima.cvs.sourceforge.net/maxima/maxima/share/contrib/amatrix/)
but as far as I can tell it does not interoperate with any existing
Maxima matrix/array functionality, so in order to calculate
scalar-matrix products, determinants, inversion, eigenvalues, etc.
etc. you need to convert back to Maxima's standard representation.

On the other hand, the particular *syntax* you propose above is quite
different from, and incompatible with, Maxima syntax, which would be
a[1..4, [1,5,6]].  Though it would be nice to benefit from
compatibility with Matlab/Octave syntax, it would also be nice to
benefit from compatibility with Mathematica, R/S-plus, SAS, Python, K,
etc. but they are all mutually incompatible and preferred by different
communities! And your proposed syntax would break much existing code,
since ":" is the assignment operator and a() is function application
(not matrix/array subscripting).

Maxima's current array/matrix semantics are a mess, I must say, with
at least four different kinds of object (hasharrays, explicit lists,
explicit matrices, Lisp arrays) supporting subscripting with varying
semantics. We really need to work on this....

> (2) All Maxima function parameters, and variables used inside a function should be automatically local variables.

Function parameters are already local variables, as in just about
every programming language.

> Global variables used inside a function must be explicitly declared as global, eg: global(x1,x2,y1). This is how Matlab works.

This is an unconventional system and will cause many surprises,
whether scope is dynamic (current Maxima semantics) or static/lexical
(most other programming languages) as well as of course breaking
existing code.  Python has yet a different system, where any variables
which are *assigned* within a function are automatically local....

> (Mathworks claims that there are over a million people using Matlab.)

Perhaps, but there are also many users of R/S, of Mathematica, of
Python, and for that matter of Fortran (!), so it's not clear that
Matlab should be our major point of reference.  That said, it is
certainly worthwhile to get ideas from Matlab as well as many other
sources.

           -s