# A metaprogramming question (sorry, can't find a more informative title)

**URL:** <https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839>\
**Category:** New to Julia\
**Created:** [February 2, 2017, 11:45am UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839 "2017-02-02T11:45:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [February 2, 2017, 11:45am UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/1 "2017-02-02T11:45:42Z")

</div>

Here is an example I took from [http://docs.julialang.org/en/stable/manual/metaprogramming/#interpolation](http://docs.julialang.org/en/stable/manual/metaprogramming/#interpolation), which confuses me.

My questions: 1. What does `$:((1,2,3))` mean? Can we think `$` and `:` as opposite operators which cancel each other, so that `$:((1,2,3))` is exactly same as the original tuple `(1,2,3)`? 2. Why `ex1 == ex2`, but not `ex1 === ex2`? Thanks!!

```julia
julia> ex1 = :(a in $:((1,2,3)) )
:(a in (1,2,3))

julia> ex2 = :(a in (1,2,3) )
:(a in (1,2,3))

julia> ex1 == ex2
true

julia> ex1 === ex2
false

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 2, 2017, 11:54am UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/2 "2017-02-02T11:54:09Z")

</div>

Even though in some contexts `$` and `:` “cancel”, I would think of `:` as a quote and `$` as a splice operator instead.

The two expressions are not `===` since they are not the same object. Eg you could

```julia
push!(ex2.args[3].args,4)

```

and it would not affect `ex1`.

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [February 2, 2017, 11:56am UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/3 "2017-02-02T11:56:58Z")

</div>

Thanks, @Tamas_Papp! Then how should I understand the following?

```julia

julia> a = 1
1

julia> b = 1
1

julia> a === b
true

```

I’m quite surprised that `a` and `b` are a same object?

---

<div class="post-metadata">

**Author:** ![pint](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pint/32/125_2.png) [@pint](https://discourse.julialang.org/u/pint)\
**Post date:** [February 2, 2017, 12:12pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/4 "2017-02-02T12:12:05Z")

</div>

expressions are objects. two objects created separately are never ===. consider

```julia
a = :(1+1); b = :(1+1); a===b
# -> false
a = []; b = []; a===b
# -> false

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 2, 2017, 12:14pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/5 "2017-02-02T12:14:06Z")

</div>

In some cases, a nice alternative to being surprised is reading the documentation:

```julia
help?> is
search: ind2sub @ip_str include_string @int128_str is isa issym isqrt isodd isnan

  is(x, y) -> Bool
  ===(x,y) -> Bool
  ≡(x,y) -> Bool

  Determine whether x and y are identical, in the sense that no program could
  distinguish them. Compares mutable objects by address in memory, and compares
  immutable objects (such as numbers) by contents at the bit level. This function
  is sometimes called egal.

```

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [February 2, 2017, 2:22pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/6 "2017-02-02T14:22:08Z")

</div>

Thanks. Can you explain the difference between your second example and the following one?

```julia
julia> a = 1
1

julia> b = 1
1

julia> a === b
true

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [February 2, 2017, 2:34pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/7 "2017-02-02T14:34:51Z")

</div>

The identity of `immutable`s (e.g. `1`) only depend on their value. The identity of mutable `type`s (e.g. `[]`) depend on their address.

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [February 2, 2017, 2:37pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/8 "2017-02-02T14:37:11Z")

</div>

Thanks for the hint. But I’m not claiming `a` or `b` as immutable. Why is there anything to do with immutable? Thanks!

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [February 2, 2017, 2:38pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/9 "2017-02-02T14:38:03Z")

</div>

immutable is a property of the type, it has nothing to do with the variable it is bound to.

---

<div class="post-metadata">

**Author:** ![chobbes](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@chobbes](https://discourse.julialang.org/u/chobbes)\
**Post date:** [February 2, 2017, 2:42pm UTC](https://discourse.julialang.org/t/a-metaprogramming-question-sorry-cant-find-a-more-informative-title/1839/10 "2017-02-02T14:42:45Z")

</div>

I see now. Just like:

```julia
julia> 1 === 1
true

julia> [] === []
false

```

Thanks!
