Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
@matlab
macro currently takes Julia syntax and tries to convert it to MATLAB syntax. This mostly works because the syntax is similar, but it is occasionally confusing and/or broken (see #26). This is an alternative approach that is hopefully both easier to use and harder to break.The
mat
string literal allows intermixing of Julia and MATLAB code, e.g.:It also allows you to use interpolation, avoiding
@mput
and@mget
entirely:or:
Finally, if an expression sets
ans
,mat
returns it, so you can write:There are a couple hacks to get this to work. First, I couldn't figure out how to get string interpolation in a custom literal without calling
parse
on the corresponding ordinary string literal, so that's what we do. Second, the code to determine whether a variable is assigned, referenced, or both can probably be fooled, although it's hard for me to come up with a case that would actually break at the moment.If this sounds good to others, we might consider deprecating
@matlab
in favor of it.