Julia provides special syntax for non-standard string literals: http://docs.julialang.org/en/release-0.2/manual/metaprogramming/?highlight=macro#non-standard-string-literals
On Fri, Feb 7, 2014 at 2:44 PM, Ismael VC <[email protected]> wrote: > What would be the difference between writing S_str as a macro and as a > function, and using different syntax to call them and get the same result? > > In Tracy's version which sintax to use, and how come only the 'S' is > needed to call the macro, and not "S_str", but it is needed when using "@": > > julia> macro S_str(e) > :(symbol($e)) > end > > julia> S"test test" > :test test > > julia> @S_str "test test" > :test test > > So in S_str "_str" denotes the parameter and "e" the argument? I think I > can see what it is doing, but I don't fully get it. > > julia> S_str"test test" > ERROR: @S_str_str not defined > > julia> @S "test test" > ERROR: @S not defined > > > Ok so this doesnt work: > > julia> function S_str(e) > :(symbol($e)) > end > S_str (generic function with 1 method) > > julia> S_str("test test") > :(symbol("test test")) > > But this does, yet it's just a wrapper: > > > julia> function S_str(e) > symbol(e) > end > S_str (generic function with 1 method) > > julia> S_str("test test") > :test test >
