[Maxima] matchfix operator declaration

Robert Dodier robert.dodier at gmail.com
Mon Sep 10 09:37:37 CDT 2007

On 9/9/07, Valery Pipin <pip at iszf.irk.ru> wrote:

> I wonder if I can reformulate  the following  part of Rules.texi:
> @code{matchfix (@var{ldelimiter}, @var{rdelimiter}, @var{arg_pos}, @var{pos})}
> declares the argument part-of-speech @var{arg_pos}
> and result part-of-speech @var{pos},
> and the delimiters @var{ldelimiter} and @var{rdelimiter}.
> what is "part-of-speech" here?  Is it just a "class" of arguments and results?

Well, "part of speech" is a rather suggestive term, but only 3
values are recognized --- 'expr 'clause 'any --- 'expr indicating
an algebraic expression, 'clause indicating a Boolean expression,
and 'any indicating any kind of expression. Probably the text for
the other operator declaration functions could be clarified with
this info as well.

The Maxima parser uses the part of speech declarations to detect
some syntax errors.

matchfix ("~", "~", expr, expr);
if ~ 1, 2 ~ then foo else bar;
 => Incorrect syntax: Found algebraic expression where logical
expression expected

matchfix ("~", "~", expr, clause);
if ~ 1, 2 ~ then foo else bar;
 => OK

I think the parser fails to detect some such errors, however.

matchfix ("~", "~", clause, expr);
~ 1, 2 ~ + 1;
 => OK (hmm, shouldn't that trigger an error?)


Robert Dodier

More information about the Maxima mailing list