bug in 'is' ?



On Mon, Feb 20, 2012 at 07:15, John Lapeyre <lapeyre.math122a at gmail.com>wrote:
...

> A related issue is, Mma gives Length[<string>] --> 0,
> maxima length(<string>) triggers a lisp error.  You could argue
> that both Mma and maxima behavior are better than returning the string
> length because Part and part won't look inside a
> string. One could change length(<string>) to return the input form with no
> message. I imagine this would cause much
> confusion because many users would try it and be confused by the results.
>

length calculates the length of a list (including argument list).  Thus
length(f(a,b)) => 2, length(a+b) == length("+"(a,b)) => 2 and length(f())
=>0.  Though logicians often treat constants as zero-argument functions,
that is not the Maxima convention: args(f) is an error, and so length(f)
should remain an error.

As for length(-1), yes, I suppose that is somewhat confusing, but Maxima
works hard (see the code in mpart, $length, nformat, etc.) to make -1 act
like "-"(1) (after all, op(-1) => "-"), so length(-1) should indeed be 1,
while length(1) should remain an error.  So block([inflag:true],length(-1))
correctly gives an error, because it is operating on the internal form,
which is the atomic -1, not the expression "-"(1).


> But, this stuff could be configurable, at different levels.


Configurability of things like this complicates the system and makes it
harder to write libraries.  Functions (sensibly) assume that the value of
length(...) is a non-negative integer and are likely to do strange things
if it is not.  I don't really see how a return value like "for i thru
length(3) do ..." could be useful to a user.

               -s