# How would you write a beautiful DSL?

**URL:** <https://discourse.julialang.org/t/how-would-you-write-a-beautiful-dsl/32241>\
**Category:** General Usage\
**Tags:** metaprogramming\
**Created:** [December 13, 2019, 6:38pm UTC](https://discourse.julialang.org/t/how-would-you-write-a-beautiful-dsl/32241 "2019-12-13T18:38:23Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![rvignolo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rvignolo/32/33498_2.png) [@rvignolo](https://discourse.julialang.org/u/rvignolo)\
**Post date:** [December 14, 2019, 3:44am UTC](https://discourse.julialang.org/t/how-would-you-write-a-beautiful-dsl/32241/21 "2019-12-14T03:44:51Z")

</div>

Doing this in the global scope leads to:

```nohighlight
x = 1
f(t) = x * t
@btime [(x, f(10)) for i in 1:10000];
2.099 ms (10004 allocations: 468.89 KiB)

```

or, equivalently:

```nohighlight
x = 1
f(x, t) = x * t
@btime [(x, f(x, 10)) for i in 1:10000];
2.177 ms (10004 allocations: 468.89 KiB)

```

Which is bad, as expected.

[Previous page](https://discourse.julialang.org/t/how-would-you-write-a-beautiful-dsl/32241.md?page=1)
