-
Notifications
You must be signed in to change notification settings - Fork 101
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
[WIP] Updated json string literal based on elcritch's work #130
Conversation
Any comments on this? Objections to merging? The test failures are on Julia master and don't relate to this PR. |
I'll be able to take a look at it soon. Hopefully tomorrow. On Mon, Dec 14, 2015 at 6:13 PM -0800, "Tom Short" [email protected] wrote: Any comments on this? Objections to merging? The test failures are on Julia master and don't relate to this PR. — |
@@ -289,4 +289,17 @@ function parsefile{T<:Associative}(filename::AbstractString; dicttype::Type{T}=D | |||
end | |||
end | |||
|
|||
# Macros | |||
str_helper(arg) = parse(arg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function can probably be taken out, parse can be used directly
As is, I'm not convinced this is useful—it doesn't save much typing over JSON.parse. It also boils down to But one feature that would be nice would be interpolation:
to produce This interpolation feature is supported by Cxx.jl, MATLAB.jl, and a similar feature has been experimentally implemented in Scala. |
|
||
let mstr_test = @compat Dict("a" => 1) | ||
@test mstr_test == json"""{"a":1}""" | ||
# Doesn't work: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the test instead of commenting it out?
@TotalVerb having string interpolation in the string macro would be very useful, IMHO. Unfortunately I couldn't find any documentation on how string interpolation is done by on normal Julia parse/compile. It appears you either get string interpolation or you can do string macros. |
String interpolation can't be done in full generality in a string macro since the parser needs to call itself recursively in order to know when the string literal ends. You can approximate it, however, by looking for |
@StefanKarpinski While what you say is entirely correct, this macro is typically used multiline, so string interpolation with string literals (as long as they are not also multiline) should work as expected. I hope to create a prototype soon. |
As I mentioned here, this macro doesn't really provide anything beyond |
The aim of this PR is to update and simplify @elcritch's PR #113.
The single-quote option is removed. There's also no option to pass the dicttype. I tried using a trailing argument for this, but I couldn't find an
eval
option that worked.It's marked as WIP because there's some extra junk in there for my failed tries to get dicttype to work. Someone else may have a suggestion. In any case, it needs to be cleaned up.