Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-argument failure of Wolfram functions #63

Closed
light-matters opened this issue Jul 1, 2024 · 5 comments
Closed

Multi-argument failure of Wolfram functions #63

light-matters opened this issue Jul 1, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@light-matters
Copy link
Contributor

For future decision, I'm separating this from the pull request that was merged.

(wl/eval (w/-)) => ERROR
(wl/eval (w/- 5 4 3)) => ERROR
(wl/eval '(w/- 5 4 3)) => ERROR
(wl/eval (w/Subtract 5 4 3)) => (Subtract 5 4 3)
(wl/eval '(w/Subtract 5 4 3)) => (Subtract 5 4 3)

with ERROR

1. Unhandled java.lang.IllegalArgumentException
   Can't handle more than 2 arguments

Note that the error message is not strictly true for the first example.

Here, we see that passing the wrong number of arguments to Wolfram functions does not fail in the way that it would if it was done directly in a Wolfram system. Using a higher-level Wolfram abstraction (-) in the Clojurey way however, does. This may end up being desired behaviour, but using '-' from within Mathematica will only fail if there is nothing else at all in the cell (incomplete expression) and will otherwise work as Subtract or Minus depending on the context.

@light-matters light-matters added the bug Something isn't working label Jul 1, 2024
@holyjak
Copy link
Member

holyjak commented Sep 17, 2024

Hm, even if Subtract[1,2,3] works, I cannot find in the docs mention of supporting more than 2 args, or how many it does support. Can you @light-matters ? -> https://reference.wolfram.com/language/ref/Subtract.html

@light-matters
Copy link
Contributor Author

Subtract[1,2,3] doesn't work. I think it only supports binary operations and is converted internally to Plus[x,-y]. I think the problem here is the inconsistent errors.

@holyjak
Copy link
Member

holyjak commented Sep 17, 2024

So if we changed the error message as

- Can't handle more than 2 arguments
+ Can't handle less than one or more than 2 arguments

then it would be fine?

@light-matters
Copy link
Contributor Author

A change in error message might help a littel, but I think my original point was that using 'Subtract doesn't 'fail' with an error, but using '-' does. I'm not sure if this is really a problem, but it's at least strange. Why is it more of a problem when there's an alias?

@holyjak
Copy link
Member

holyjak commented Sep 22, 2024

#123 makes sure that Subtract with incorrect args also fails.

@holyjak holyjak closed this as completed Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants