Menu

#1355 ev doesn't work as expected with subscripted variables

None
open
nobody
5
2024-06-03
2008-02-21
David Ronis
No

f(l,m):=A[l,m]+B[l,m]+A[l+1,m];
ev(f(l,m), A[l,m]=0);

A[l,m] still appears in the result.

However,

f(l,m);
ev(%, A[l,m]=0 );

works as expected.

Discussion

  • Stavros Macrakis

    Logged In: YES
    user_id=588346
    Originator: NO

    Thanks for the bug report. EV is a very funny function, and often produces peculiar surprises like this.

    I hope we'll be able to fix this at some point, but in the meantime, I'd suggest you use subst to evaluate things like this:

    subst([a[l,m]=0],f(l,m))

    instead of ev.

     
  • Robert Dodier

    Robert Dodier - 2008-06-21

    Logged In: YES
    user_id=501686
    Originator: NO

    For the record, my comments on this problem 2008-02-21:

    Well, the mechanism for saving and restoring local variables handles only simple variables (not
    subscripted variables). ev substitutes for subscripted variables instead. But substitution doesn't have quite the same effect, as you have observed. See $EV in src/mlisp.lisp.

    This is a bug; I guess it could be fixed by making MBIND and friends happy with subscripted variables. Dunno if that would cause trouble elsewhere.

     
  • Robert Dodier

    Robert Dodier - 2008-06-21
    • labels: 870406 --> Lisp Core
     
  • Robert Dodier

    Robert Dodier - 2024-05-31
    • labels: Lisp Core --> ev, subscripted variables
    • Group: --> None
     
  • Viktor Toth

    Viktor Toth - 2024-06-03

    Isn't this "behavior by design"? I note that ev(f(l,m),A[l,m]=0,eval) works fine, which seems to be in line with my understanding of how ev() is supposed to function, but perhaps I misunderstood the intended behavior.

     

Log in to post a comment.