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

Function calls aren't translated correctly #4

Open
nilshg opened this issue Mar 29, 2019 · 3 comments
Open

Function calls aren't translated correctly #4

nilshg opened this issue Mar 29, 2019 · 3 comments

Comments

@nilshg
Copy link

nilshg commented Mar 29, 2019

MATLAB: my_function(arg1, arg2)
Julia: my_function[arg1, arg2]

Came across this bug from a user report on: https://discourse.julialang.org/t/methoderror-no-method-matching-getindex/22496/3

@lakras
Copy link
Owner

lakras commented Mar 29, 2019

Hi! Thanks so much for letting me know about this. It's tricky to know whether something is a function or a matrix in MATLAB. The script tries to guess, using a list of common functions and using functions that it sees are defined in the block of code being translated. If the translator misses something, names of functions can be added to the "interpret as functions" list in the advanced options below the translator.

I definitely don't recommend translating code and running it as is. The translator is meant to be a time-saver, but still requires learning Julia, manually correcting the translated code, and actually optimizing the code once it is translated.

That said, the translator does not currently recognize some functions that don't return anything (second option in the answer here: https://stackoverflow.com/questions/12992619/can-a-function-be-created-in-matlab-that-returns-nothing )—I'll look into fixing that!

Thanks again!

@nilshg
Copy link
Author

nilshg commented Mar 29, 2019

Sure, do understand that - I don't think there's necessarily a solution here apart from maybe mentioning this prominently somewhere, as this is probably a reasonably common problem!

@lakras
Copy link
Owner

lakras commented Mar 31, 2019

I added support for functions that don't return anything. Assuming all the code is pasted in together, the function in Aquaman's code should now actually be recognized as a function (yay!). If the function call and the actual function are not entered in together then, of course, the function will not be recognized as a function.

Leaving this open (?) since this is a problem that cannot really solved, but can be gradually improved upon. Any ideas or pull requests to make things better are absolutely welcome. (I'm opening a related issue on mapping common MATLAB functions and packages to Julia.)

@lakras lakras changed the title Function calls aren't tranlated correctly Function calls aren't translated correctly Mar 31, 2019
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

2 participants