# How does the string pkg"..." work?

**URL:** <https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711>\
**Category:** General Usage\
**Created:** [September 10, 2023, 1:19am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711 "2023-09-10T01:19:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 10, 2023, 1:19am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/1 "2023-09-10T01:19:58Z")

</div>

What magic is involved when I write

```julia
macro pkg_str(s)
    return esc(s)
end
@info pkg"Top of the morning to you, squire!"

```

Does the macro compiler “know” that this means “call `@pkg_str` when you see pkg as a string prefix”?

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [September 10, 2023, 1:28am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/2 "2023-09-10T01:28:02Z")

</div>

I think from here [https://github.com/JuliaLang/julia/blob/bbbcc4fed67337c038b485f00677e2e88d24becd/src/julia-parser.scm#L1293-L1298](https://github.com/JuliaLang/julia/blob/bbbcc4fed67337c038b485f00677e2e88d24becd/src/julia-parser.scm#L1293-L1298) it just knows how to parse it correctly, using [https://github.com/JuliaLang/julia/blob/bbbcc4fed67337c038b485f00677e2e88d24becd/src/julia-parser.scm#L1180-L1183](https://github.com/JuliaLang/julia/blob/bbbcc4fed67337c038b485f00677e2e88d24becd/src/julia-parser.scm#L1180-L1183)

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 10, 2023, 1:31am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/3 "2023-09-10T01:31:57Z")

</div>

Thanks, Daniel. Did I miss this in the Julia manual? Or is it there somewhere?

---

<div class="post-metadata">

**Author:** ![DanielVandH](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/danielvandh/32/31134_2.png) [@DanielVandH](https://discourse.julialang.org/u/DanielVandH)\
**Post date:** [September 10, 2023, 1:33am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/4 "2023-09-10T01:33:58Z")

</div>

I’m not sure if it’s specifically mentioned in the docs. The only place I can see it is here [Julia ASTs · The Julia Language](https://docs.julialang.org/en/v1/devdocs/ast/#Strings) which technically shows the parsing I guess.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [September 10, 2023, 1:38am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/5 "2023-09-10T01:38:10Z")

</div>

Cool, you’re a 🧙

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [September 10, 2023, 2:33am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/6 "2023-09-10T02:33:17Z")

</div>

Here’s where JuliaSyntax.jl parses makes macro calls out of literals, since it seems it’ll be in 1.10+: [https://github.com/JuliaLang/JuliaSyntax.jl/blob/main/src/literal\_parsing.jl#L429-L434](https://github.com/JuliaLang/JuliaSyntax.jl/blob/main/src/literal_parsing.jl#L429-L434). The handling of the input string as raw or standard seems to come in a subsequent `parse_julia_literal` call.

---

<div class="post-metadata">

**Author:** ![PeterSimon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petersimon/32/25193_2.png) [@PeterSimon](https://discourse.julialang.org/u/PeterSimon)\
**Post date:** [September 10, 2023, 3:16am UTC](https://discourse.julialang.org/t/how-does-the-string-pkg-work/103711/7 "2023-09-10T03:16:50Z")

</div>

> [@PetrKryslUCSD](#):
>
> Did I miss this in the Julia manual? Or is it there somewhere?

See the manual section on [Non-Standard String Literals](https://docs.julialang.org/en/v1/manual/metaprogramming/#meta-non-standard-string-literals)
