Menu

#4376 ev(a+b,[a,b]:[2,3]) doesn't bind a and b or give an error

None
not-a-bug
nobody
None
5
2026-03-28
2024-09-20
No
ev(a+b,[a,b]:[2,3]) => a+b
ev(a+b,[a,b]=[2,3]) => a+b
a+b,[a,b]:[2,3] => a+b    <<< the command-line short form
a+b,[a,b]=[2,3] => a+b

I think a reasonable user would expect the parallel bindings in ev to function just like parallel assignment (even though that's not promised in the manual).
At the very least, this should cause an error.
This shouldn't be that hard to implement, since after all, ev bindings are already parallel, not sequential:

[a,b],b=a,a=b => [b,a]

I came across this case because I happened to have some parameter values in list form.

Related

Bugs: #4377

Discussion

  • Stavros Macrakis

    • summary: ev(a+b,[a,b]:[2,3] doesn't bind a and b --> ev(a+b,[a,b]:[2,3] doesn't bind a and b or give an error
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -5,6 +5,7 @@
     a+b,[a,b]=[2,3] =&gt; a+b
     ~~~
     I think a reasonable user would expect the parallel bindings in ``ev`` to function just like parallel assignment (even though that&#39;s not promised in the manual).
    +At the very least, this should cause an error.
     This shouldn&#39;t be that hard to implement, since after all, ``ev`` bindings are already parallel, not sequential:
     ~~~
     [a,b],b=a,a=b =&gt; [b,a]
    
     
  • Stavros Macrakis

    • summary: ev(a+b,[a,b]:[2,3] doesn't bind a and b or give an error --> ev(a+b,[a,b]:[2,3]) doesn't bind a and b or give an error
     
  • Kris Katterjohn

    Kris Katterjohn - 2024-11-29

    I agree that a user might expect parallel bindings here, but the documentation for ev describes what's going on:

    V: expression (or alternately V=expression) causes V to be bound to the value of expression during the evaluation of expr. [...] If V is a non-atomic expression then a substitution rather than a binding is performed.

    I don't have access to a newer Maxima version at the moment, but here are some quick examples using an older version that I currently have access to:

    (%i1) ev(a + b, [a, b] = [1, 2]);
    (%o1) b+a
    
    (%i2) ev(a + b, a + b = [1, 2]);
    (%o2) [1,2]
    
    (%i3) ev(a + b, a + b = foo);
    (%o3) foo
    
    (%i4) ev([a, b], [a, b] = [1, 2]);
    (%o4) [1,2]
    
    (%i5) ev([a, b], [a, b] = bar);
    (%o5) bar
    
     
  • Jaime E. Villate

    In addition to ev and makelist, subst does not make these kind of multiple substitutions either:

    (%i1) subst([a,b]=[3,4],a+b);
    (%o1) b + a
    
     
  • Kris Katterjohn

    Kris Katterjohn - 2026-03-28
    • status: open --> not-a-bug
     
  • Kris Katterjohn

    Kris Katterjohn - 2026-03-28

    This ticket has been sitting for a while, so I'm closing this as not-a-bug based on my previous comment which showed that this is the documented behavior.

    Please comment and/or re-open if you disagree.

     

Log in to post a comment.

MongoDB Logo MongoDB