# Which symbols are special cased in the same way as \`.\*\`, \`.+\`, etc

**URL:** <https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849>\
**Category:** Internals & Design\
**Tags:** parsing\
**Created:** [October 22, 2020, 9:57pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849 "2020-10-22T21:57:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 22, 2020, 9:57pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849/1 "2020-10-22T21:57:18Z")

</div>

I am working on something in DataFramesMeta where I take an expression

```julia
z = :x + :y 

```

if, like the expression above, the RHS is of the form `+(:x, :y)`, then I can use DataFrames to create the object

```julia
[:x, :y] => (+) => :y 

```

Importantly, we use `+` rather than create an anonymous function from the expression. If, for example, we had seen

```julia
y = :x + :y .* :x

```

then the expression is not of the form `Expr(:call, :f, :x, :y)` and therefore I have to define an anonymous function and create something like

```julia
function _f(x, y)
    x + y .* x
end
[:x, :y] => _f => :z

```

this incurs a compile time cost.

Here’s the problem, the expression

```julia
z = :x .* :y 

```

creates an expression

```julia
julia> dump(:(:x .* :y))
Expr
  head: Symbol call
  args: Array{Any}((3,))
    1: Symbol .*
    2: QuoteNode
      value: Symbol x
    3: QuoteNode
      value: Symbol y

```

This _looks like_ I should be able to write

```julia
[:x, :y] => (.*) => :z 

```

However `.*` is not a function. So using `transform` on the above expression fails.

Is there anyway for me to know, just by examining the expression, that `.*` is not a function and I can’t use my little trick to reduce compilation time.

My only thought currently is to look at the first character of `string(:.*)`.

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [October 22, 2020, 9:58pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849/2 "2020-10-22T21:58:59Z")

</div>

> [@pdeffebach](#):
>
> However `.*` is not a function. So using `transform` on the above expression fails

Checkout the latest master! 🙂

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 22, 2020, 10:00pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849/3 "2020-10-22T22:00:03Z")

</div>

Thanks! Can you point me to the issue or PR that does this?

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [October 22, 2020, 10:04pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849/4 "2020-10-22T22:04:20Z")

</div>

It’s [https://github.com/JuliaLang/julia/pull/37583](https://github.com/JuliaLang/julia/pull/37583). If you need this for older versions of Julia as well, it would be fairly easy to add support for at least a limited number of operators in Compat.jl, if you are interested in this.

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [October 22, 2020, 10:05pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849/5 "2020-10-22T22:05:52Z")

</div>

Thanks! This is wonderful! If it’s going to be in 1.6 I would probably just add an `if` statement for the version and not worry about Compat.

Good to know this will be taken care of!

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [October 22, 2020, 10:15pm UTC](https://discourse.julialang.org/t/which-symbols-are-special-cased-in-the-same-way-as-etc/48849/6 "2020-10-22T22:15:33Z")

</div>

If anyone is interested in taking a stab at this for Compat.jl, the basic gist is that you would just copy the definition of `Base.BroadcastFunction` from that linked PR, and then simply do:

```julia
for op in [:+, :*]
    @eval const $(Symbol(:., op)) = BroadcastFunction($op)
end

```

for a bunch of operators. This will allow you to use `.*` as a standalone function on earlier Julia versions.
