Julia LanguageString Macros


Syntax

  • macro"string" # short, string macro form
  • @macro_str "string" # long, regular macro form
  • macro`command`

Remarks

String macros are not quite as powerful as plain old strings — because interpolation must be implemented in the macro's logic, string macros are unable to contain string literals of the same delimiter for interpolation.

For instance, although

julia> "$("x")"
"x"

works, the string macro text form

julia> doc"$("x")"
ERROR: KeyError: key :x not found

gets parsed incorrectly. This can be somewhat mitigated by using triple-quotes as the outer string delimiter;

julia> doc"""$("x")"""
"x"

does indeed work properly.