]> www.ginac.de Git - ginac.git/commit
match: don't modify subexpression list if expression doesn't match the pattern.
authorAlexei Sheplyakov <varg@theor.jinr.ru>
Tue, 15 Jul 2008 17:08:22 +0000 (21:08 +0400)
committerAlexei Sheplyakov <varg@theor.jinr.ru>
Tue, 9 Sep 2008 10:17:07 +0000 (14:17 +0400)
commit192ed7390b7b2b705ad100e3db0a92eedd2b20ad
treef1ab70ed602a5876e8ee4b358290faf63d6e0558
parentaff357309f6611a59efb10d06d3dcfd3812a9ec5
match: don't modify subexpression list if expression doesn't match the pattern.

As of now the match() method modifies the list of matched subexpressions
(its second argument) even if the expression in question does not match
the pattern. Thus, this simple program

 #include <ginac/ginac.h>
 #include <iostream>
using namespace GiNaC;

int main(int argc, char** argv)
{
symbol x;
ex e = pow(x, 5);
ex pattern = pow(wild(), -1);
lst repl;
bool test = e.match(pattern, repl);
std::cout << "repl = " << repl << std::endl;
}

prints

repl = {x}

Such behaviour is a bit unexpected. Sometimes it confuses even GiNaC
developers, see e.g.
http://www.ginac.de/pipermail/ginac-devel/2006-April/000942.html

Hence this patch. Now the above program prints

repl = {}

as expected.
doc/tutorial/ginac.texi
ginac/basic.cpp