Julia Language String Macros

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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.



Got any Julia Language Question?