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

Multiple returns #41

Open
BeastyBlacksmith opened this issue May 19, 2020 · 4 comments
Open

Multiple returns #41

BeastyBlacksmith opened this issue May 19, 2020 · 4 comments

Comments

@BeastyBlacksmith
Copy link
Contributor

In a Mathematica notebook, every line that doesn't end with ; will be displayed/ returned.
This is handled differently in MathLink where only one return value is possible.
MWE:

W```
       a = 1;
       b = 2
       c = 3
       ``` |> weval
┌ Warning: Set::write: Tag Times in 2 c is Protected.
└ @ MathLink ~/.julia/packages/MathLink/6K9ao/src/eval.jl:16
3

I would expect to get the tuple (2, 3) back.

@simonbyrne
Copy link
Member

It isn't being parsed correctly:

julia> ex = W```
           a = 1;
           b = 2
           c = 3
       ```
W"CompoundExpression"(W"Set"(W"a", 1), W"Set"(W"b", W"Set"(W"Times"(2, W"c"), 3)))

i.e. it is being parsed as a = 1; (b = ((2*c) = 3)). I'm not sure why it would be different.

@BeastyBlacksmith
Copy link
Contributor Author

I'm not sure why it would be different.

I don't understand. What would be different?

@simonbyrne
Copy link
Member

Why it parses differently in Mathematica notebooks than via calling ToExpression

@asdasd1dsadsa
Copy link

a = 1;
b = 2
c = 3

is not an expression. But

(
a = 1;
b = 2
c = 3
)

is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants