# Annotation lik @foo\_str but for numbers?

**URL:** <https://discourse.julialang.org/t/annotation-lik-foo-str-but-for-numbers/65638>\
**Category:** General Usage\
**Tags:** macros\
**Created:** [August 1, 2021, 5:19pm UTC](https://discourse.julialang.org/t/annotation-lik-foo-str-but-for-numbers/65638 "2021-08-01T17:19:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tpoisot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tpoisot/32/19812_2.png) [@tpoisot](https://discourse.julialang.org/u/tpoisot)\
**Post date:** [August 1, 2021, 5:19pm UTC](https://discourse.julialang.org/t/annotation-lik-foo-str-but-for-numbers/65638/1 "2021-08-01T17:19:02Z")

</div>

I can define a `@foo_str` macro, which lets me write `foo"something"`. Is there an equivalent mechanism for numbers? The closest I can think if in Julia would be something like `2im`, so this can probably be achieved using units, but I’m wondering about a more general solution.

Note that I don’t have a specific use case in mind, I was just wondering about, say, `@matchbox_int` to write code like `matchbox20`, which would for example generate bland post-grunge sounds.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 1, 2021, 6:08pm UTC](https://discourse.julialang.org/t/annotation-lik-foo-str-but-for-numbers/65638/2 "2021-08-01T18:08:42Z")

</div>

No, there is nothing like string macros for numbers. `im` works by overloading `*`, since `1im` is juxtaposed multiplication of `1` and `im`:

```julia
julia> @which 1im                                     
*(x::Real, z::Complex{Bool}) in Base at complex.jl:321

julia> @which 1*im                                     
*(x::Real, z::Complex{Bool}) in Base at complex.jl:321
                                                      
julia> typeof(im)                                     
Complex{Bool}                                         

```

You can use the same trick in your own code though (and I believe that’s how e.g. Unitful.jl does it as well). It also only works if the constant is written after the number literal, since otherwise it’s parsed as a single identifier:

```julia
julia> im1                           
ERROR: UndefVarError: im1 not defined

```
