Hi,
Resurrecting an old thread :)
Hmm... I was recently playing around with MATLAB.jl and fell in love with
the mat"" syntax. I've also been playing around with getting Julia and JS
to talk to each other (and, by extension, JS talking to Matlab via Julia)
and I'd really like to be able to do things like:
julia>js"""
console.log("Hello from Julia!")
"""
Reading Stefan's suggestions, I was able to get this to work (without
Blink.jl or Electron):
julia>js("""
console.log("Hello from Julia!")
""")
My inability to get the non-standard string literal to work with
interpolation is bugging me.
As a start, can someone help me understand the difference between:
julia> @js_str "x = $x"
and
julia>js"x = $x"
As a little experiment, I tried the following:
function js(ex::AbstractString)
println("AbstractString:")
println(ex)
end
function js(ex::Expr)
println("Expression:")
println(ex)
end
macro js_str(ex)
js(ex)
end
with the following results:
julia> @js_str "x = $x"
Expression:
"x = $(x)"
julia> js"x = $x"
AbstractString:
x = $x
Why is the first one an expression and the second one a string? I kind of
expected the two lines above to be the same.
I did peak under the hood of MATLAB.jl to see how @mat_str was defined and
found scary words like "DumbParser" and "Hack to do interpolation" followed
by tons of scary code. I suppose this is also what jsexprs.jl is all about
in Blink.jl too.
There's got to be a better way? :)