# Function call with quotes instead of parenthesis

**URL:** <https://discourse.julialang.org/t/function-call-with-quotes-instead-of-parenthesis/114382>\
**Category:** General Usage\
**Tags:** syntax\
**Created:** [May 17, 2024, 1:36am UTC](https://discourse.julialang.org/t/function-call-with-quotes-instead-of-parenthesis/114382 "2024-05-17T01:36:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TI36XPro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ti36xpro/32/33658_2.png) [@TI36XPro](https://discourse.julialang.org/u/TI36XPro)\
**Post date:** [May 17, 2024, 1:36am UTC](https://discourse.julialang.org/t/function-call-with-quotes-instead-of-parenthesis/114382/1 "2024-05-17T01:36:59Z")

</div>

Hello,

I was looking at the [LocalRegistry](https://github.com/GunnarFarneback/LocalRegistry.jl) package when I noticed the following (unrelated I think to the actual LocalRegistry package).

```julia
using Pkg
pkg"registry add <repository url>"

```

It looks like the quotes are used instead of parenthesis? I guess I was expecting

```julia
pkg("registry add <repository url>")

```

But if I do `? pkg` it tells me that `pkg` is not a function.

What is this syntax? I googled around a bit but might’ve missed it in the manual.

---

<div class="post-metadata">

**Author:** ![screw\_dog](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/screw_dog/32/48119_2.png) [@screw\_dog](https://discourse.julialang.org/u/screw_dog)\
**Post date:** [May 17, 2024, 1:46am UTC](https://discourse.julialang.org/t/function-call-with-quotes-instead-of-parenthesis/114382/2 "2024-05-17T01:46:57Z")

</div>

These are called [“non-standard string literals”](https://docs.julialang.org/en/v1/manual/metaprogramming/#meta-non-standard-string-literals).

What you are seeing is a string (`"registry add <repository url>"`) that is being passed to a macro (`@pkg_str`). This is a … slightly strange usage of this syntax sugar which is typically used for processing a string into something string-like (ie a regex, byte array, etc).

The main difference between a macro like this and a function is that the macro processing occurs once - during compilation, the function processing occurs every time it’s called. So using `r"regex"` allows it to be precompiled.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [May 17, 2024, 5:33am UTC](https://discourse.julialang.org/t/function-call-with-quotes-instead-of-parenthesis/114382/3 "2024-05-17T05:33:48Z")

</div>

> [@screw\_dog](#):
>
> This is a … slightly strange usage of this syntax

I assume it is supposed to mirror the syntax from the [package REPL mode](https://docs.julialang.org/en/v1/stdlib/REPL/) so that typing `pkg"add SomePackage"` or whatever other operations, is equivalent to activating the Pkg mode (by typing `]` and getting the `pkg>` prompt) and just writing

```julia
pkg> add SomePackage

```

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [May 17, 2024, 7:42am UTC](https://discourse.julialang.org/t/function-call-with-quotes-instead-of-parenthesis/114382/4 "2024-05-17T07:42:07Z")

</div>

That’s exactly what it does.

For the record, to add a registry with an API call requires

```julia
Registry.add(RegistrySpec(url = repository_url))

```

which I find too annoying even for something that can just be copy-and-pasted.

This will improve with [Simplify Pkg.Registry APIs. by GunnarFarneback · Pull Request #3785 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/pull/3785) so it can be written

```julia
Registry.add(url = repository_url)

```

which I will change to in the LocalRegistry documentation once that feature is generally available.
