# Applying a macro to a variable

**URL:** <https://discourse.julialang.org/t/applying-a-macro-to-a-variable/92188>\
**Category:** General Usage\
**Created:** [December 27, 2022, 1:55pm UTC](https://discourse.julialang.org/t/applying-a-macro-to-a-variable/92188 "2022-12-27T13:55:12Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [January 6, 2023, 11:18pm UTC](https://discourse.julialang.org/t/applying-a-macro-to-a-variable/92188/10 "2023-01-06T23:18:40Z")

</div>

We can also construct `Tuple`s, which can be faster:

```julia
julia> IJ(n) = [i for i = 0:n for j = 0:n-i], [j for i = 0:n for j = 0:n-i]
IJ (generic function with 1 method)

julia> @btime IJ(5);
  257.353 ns (8 allocations: 1.06 KiB)

julia> IJ2(n) = ((i for i = 0:n for j = 0:n-i)...,), ((j for i = 0:n for j = 0:n-i)...,)
IJ2 (generic function with 1 method)

julia> @btime IJ2(5);
  4.300 ns (0 allocations: 0 bytes)

```

though you have to avoid the `Tuple` constructor because it’s [type-unstable](https://discourse.julialang.org/t/generator-slow-when-passed-as-argument/91606):

```julia
julia> IJ3(n) = Tuple(i for i = 0:n for j = 0:n-i), Tuple(j for i = 0:n for j = 0:n-i)
IJ3 (generic function with 1 method)

julia> @btime IJ3(5);
  1.900 μs (11 allocations: 1.77 KiB)

```

---

_[View the full topic](https://discourse.julialang.org/t/applying-a-macro-to-a-variable/92188)._
