# Documentation for suffixes of string macros?

**URL:** <https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658>\
**Category:** General Usage\
**Tags:** documentation, macros\
**Created:** [September 25, 2026, 12:31am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658 "2026-09-25T00:31:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [September 25, 2026, 12:31am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/1 "2026-09-25T00:31:48Z")

</div>

The README file on GitHub mentions that StaticStrings.jl uses string macros of the form `static"Hello world!"12` which take more than one parameter. I didn’t know that this is possible. Is this described anywhere in the Julia documentation? If not, what exactly are the rules?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [September 25, 2026, 12:38am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/2 "2026-09-25T00:38:53Z")

</div>

See the section just above Generated Functions:

> **[Generated functions - Metaprogramming · The Julia Language](https://docs.julialang.org/en/v1/manual/metaprogramming/#Generated-functions)**
>
> The strongest legacy of Lisp in the Julia language is its metaprogramming support. Like Lisp, Julia represents its own code as a data structure of the language itself. Since code is represented by objects that can be created and manipulated from...

> Another way to define a macro would be like this:

```julia-auto
macro foo_str(str, flag)
    # do stuff
end

```

> This macro can then be called with the following syntax:

```julia-auto
foo"str"flag

```

> The type of flag in the above mentioned syntax would be a String with contents of whatever trails after the string literal.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 25, 2026, 12:40am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/3 "2026-09-25T00:40:36Z")

</div>

> [@matthias314](#):
>
> Is this described anywhere in the Julia documentation?

It’s not documented super clearly in the manual at the moment, it seems — this should really be fixed.

The way it works is that any suffix after the string is parsed as a second argument to the string macro:

```julia-auto
julia> macro foo_str(str, suffix="default")
         @show str
         @show suffix
         str
       end
@foo_str (macro with 2 methods)

julia> foo"string"
str = "string"
suffix = "default"
"string"

julia> foo"string"xyz
str = "string"
suffix = "xyz"
"string"

```

I’m not 100% sure what the rules are for parsing the suffix. It looks like most things get parsed as a string, but numbers get parsed as numbers:

```julia-auto
julia> foo"string"1
str = "string"
suffix = 1
"string"

julia> foo"string"1.
str = "string"
suffix = 1.0
"string"

```

---

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [September 25, 2026, 12:58am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/4 "2026-09-25T00:58:54Z")

</div>

Thanks to both you!

I think it would help to use the word “string macro” in addition to “string literal” when discussing this in the documentation. The concept is referred to as “string macro” in several places in the documentation, but not where they are explained. So a full-text search doesn’t help.

---

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [September 25, 2026, 3:09am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/5 "2026-09-25T03:09:38Z")

</div>

So can we expect your PR, @matthias314? 😉

I think making the wording consistent in the documentation and possibly add some more linking between the places would be a welcomed contribution. It sounds like you just got already kind of an overview.

---

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [September 26, 2026, 12:13am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/6 "2026-09-26T00:13:05Z")

</div>

I can make a PR to add the “string macro” terminology, but I wouldn’t say that I have an overview. I don’t know more about the parsing of the suffix than what @stevengj said. It could be that numbers (including `Bool`) are parsed as such (contradicting the docs) and everything else as a string. The end of the string seems to be the next space/newline character or an operator or maybe even something else.

---

<div class="post-metadata">

**Author:** ![PatrickHaecker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/patrickhaecker/32/222891_2.png) [@PatrickHaecker](https://discourse.julialang.org/u/PatrickHaecker)\
**Post date:** [September 26, 2026, 8:53am UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/7 "2026-09-26T08:53:10Z")

</div>

That is probably the second step. Making it more likely to find what is already there (i.e. consistent wording + potentially links) would already be a good first step.

I was not referring to that second step and the truth is probably in the source. But as an aside, what I like to do in cases like this, is to (mis)use `Expr` to answer what Julia does:

```julia-auto
julia> :(abc"def"1.2) |> dumpstrip
Expr
  head: Symbol macrocall
  args: Array{Any}((3,))
    1: Symbol @abc_str
    2: String "def"
    3: Float64 1.2

julia> :(abc"def"123ghi) |> dumpstrip
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol *
    2: Expr
      head: Symbol macrocall
      args: Array{Any}((3,))
        1: Symbol @abc_str
        2: String "def"
        3: Int64 123
    3: Symbol ghi

julia> :(abc"def"ghi123) |> dumpstrip
Expr
  head: Symbol macrocall
  args: Array{Any}((3,))
    1: Symbol @abc_str
    2: String "def"
    3: String "ghi123"

```

That’s also a quick way when you see an expression and wonder how the operator precedence plays out. You can use `dump` if you do not have a suitable `dumpstrip` in your startup which removes the `LineNumberNode`s (removing them like here is only suitable for dumping).

---

<div class="post-metadata">

**Author:** ![matthias314](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@matthias314](https://discourse.julialang.org/u/matthias314)\
**Post date:** [October 3, 2026, 5:09pm UTC](https://discourse.julialang.org/t/documentation-for-suffixes-of-string-macros/139658/8 "2026-10-03T17:09:19Z")

</div>

> [@PatrickHaecker](#):
>
> So can we expect your PR

> <https://github.com/JuliaLang/julia/pull/63555>
>
> Following the discussion on \[Discourse\](https://discourse.julialang.org/t/docume…ntation-for-suffixes-of-string-macros/139658), here is my attempt at improving the documentation for string macros. The PR has two parts:
> 
> \- The first commit adds the words "string macro" to the relevant section, besides the current wording "non-standard string literal". Otherwise a full-text search for "string macro" will not get a user there.
> \- The second commit clarifies the type of the optional trailing parameter. Despite what is currently said in the documentation, it's not always a \`String\`. It can also be a numeric literal. I've written down my guess of how it works. I would be good if somebody who knows the internals could check and correct the text if necessary.

As said in the PR, it would be good if somebody who knows the internals could check the claim about the parsing of the trailing parameter.
