# "literals" in Julia: "immutable values known at compile times"?

**URL:** <https://discourse.julialang.org/t/literals-in-julia-immutable-values-known-at-compile-times/25145>\
**Category:** General Usage\
**Created:** [June 11, 2019, 12:58pm UTC](https://discourse.julialang.org/t/literals-in-julia-immutable-values-known-at-compile-times/25145 "2019-06-11T12:58:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [June 11, 2019, 12:58pm UTC](https://discourse.julialang.org/t/literals-in-julia-immutable-values-known-at-compile-times/25145/1 "2019-06-11T12:58:03Z")

</div>

Would be correct to say that literals in Julia are “immutable values known at compile times” ?

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [June 11, 2019, 1:03pm UTC](https://discourse.julialang.org/t/literals-in-julia-immutable-values-known-at-compile-times/25145/2 "2019-06-11T13:03:30Z")

</div>

IMO, the statement is correct, but not precise.

```julia
struct MyStruct
  x
end

const m = MyStruct(5)

```

Here, `m` holds an immutable value known at compile time as well. But this value isn’t a literal. (please correct me if I’m wrong)

---

<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:** [June 11, 2019, 1:09pm UTC](https://discourse.julialang.org/t/literals-in-julia-immutable-values-known-at-compile-times/25145/3 "2019-06-11T13:09:20Z")

</div>

Depends on what do you call literal and what do you want to get from this statement…

If you are only talking about strings and builtin numbers, sure, but that’s nothing more than saying strings and builtin numbers are immutable types (actually that’s already questionable for `BigInt` and `BigFloat`). It has nothing to do with “literal”.

We also have string macros that are basically user-defined literals in C++. They can construct either mutable or immutable objects and they may or may not be known at compile time.

If you define only those that are immutable and known at compile time as literals, then yes, but that’s just the definition and doesn’t really carry much more meaning.
