Question: patmatch fails when called from another proc() but not from global

I am learning patmatch. And found strange problem.

When I make an expression inside a proc A, and pass this expression to another proc B, which then uses patmatch  on it, the pattern fails to match.

but calling proc B directly, with exactly same expression, patmatch does match.

This is confusing and not sure why it happens. It seems related to using symbol which was declared local vs. same symbol but is global. Here is an example

restart;
foo:=proc()
  local x,C1;
  boo(exp(C1+x));
end proc;

boo:=proc(expr)
  local a,b,c,la;
  patmatch(expr,a::anything*exp(b::anything*C1+c::anything),'la');
end proc;

Call to foo() returns false. But call to boo() returns true. Even though I am using same expression.

foo();
   false


C1:='C1':
x:='x':
boo(exp(C1+x));
   true

  

What Am I doing wrong, and how to make it work in both cases?

Please Wait...