On 5/9/07, Stavros Macrakis <macrakis at alum.mit.edu> wrote:
> On 5/8/07, Robert Dodier <robert.dodier at gmail.com> wrote:
> > That's a feature of PART+ . a2 sweeps up all the atoms in the sum,
> > and then PART+ tries to match 0 to any match variables not yet
> > assigned anything.
>
> Is this documented anywhere!? It was certainly a surprise to me that a
> match-variable matching atom matches something other than an atom!
This topic is mentioned in the info for matchdeclare.
If an expression satisfies a match predicate, the match variable
is assigned the expression, except for match variables which are
operands of addition `+' or multiplication `*'. Only addition and
multiplication are handled specially; other n-ary operators (both
built-in and user-defined) are treated like ordinary functions.
In the case of addition and multiplication, the match variable may
be assigned a single expression which satisfies the match
predicate, or a sum or product (respectively) of such expressions.
The text for matchdeclare and tellsimpafter (and various other things)
represents what I was able to puzzle out by reading the code and
trying a lot of examples. FWIW.
I see the matchdeclare info doesn't mention the match-to-0 bit.
Well, there's a limit to how much detail is useful; and a limit
to the patience of the documentation author.
Robert