# Why does a macro fail if passed constructed symbols as arguments?

**URL:** <https://discourse.julialang.org/t/why-does-a-macro-fail-if-passed-constructed-symbols-as-arguments/85221>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 3, 2022, 11:26am UTC](https://discourse.julialang.org/t/why-does-a-macro-fail-if-passed-constructed-symbols-as-arguments/85221 "2022-08-03T11:26:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Soldalma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/soldalma/32/29388_2.png) [@Soldalma](https://discourse.julialang.org/u/Soldalma)\
**Post date:** [August 3, 2022, 11:26am UTC](https://discourse.julialang.org/t/why-does-a-macro-fail-if-passed-constructed-symbols-as-arguments/85221/1 "2022-08-03T11:26:56Z")

</div>

This code works produces a nice chart:

```julia
using DataFrames, StatsPlots

df = DataFrame(A = rand(20), C = repeat([1,2,3, 4], inner = 5))

plt_dens1 = @df df density(
    :A,
    group = :C,
    title = "This works"
)

```

If the Symbol arguments are constructed as below, code that is similar does not work. It generates an error message starting with:

`"ERROR: MethodError: no method matching _extract_group_attributes(::Symbol, ::Symbol)" is generated."`

```julia
asymb = Symbol("A")
csymb = Symbol("C")

plt_dens2 = @df df density(
    asymb,
    group = csymb,
    title = "This doesn't work"
)

```

Question: Does this mean Julia does not respect referential transparency?

Fortunately this code generates a chart just like the first one:

```julia
plt_dens3 = @df df density(
    df[:, Symbol("A")],
    group = df[:, Symbol("C")],
    title = "This also works"
)

```

However, it is a little more cumbersome.

Question: Why doesn’t the code for plt\_dens2 work and is there a simple way to fix the problem?
