# Include a script from external file in different scopes

**URL:** <https://discourse.julialang.org/t/include-a-script-from-external-file-in-different-scopes/1431>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 12, 2017, 12:50pm UTC](https://discourse.julialang.org/t/include-a-script-from-external-file-in-different-scopes/1431 "2017-01-12T12:50:17Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 12, 2017, 2:40pm UTC](https://discourse.julialang.org/t/include-a-script-from-external-file-in-different-scopes/1431/5 "2017-01-12T14:40:21Z")

</div>

Here’s a macro which generates macros like that:

> [@\`@def\` macro generator broken on master](https://discourse.julialang.org/t/def-macro-generator-broken-on-master/1096/3):
>
> I see, name wasn’t escaped: macro def(name, definition) return quote macro $(esc(name))() esc($(Expr(:quote, definition))) end end end @def test begin a = 2 end # Now @test "pastes" the code `a=2` is good now.

Use with caution. (The fixed version includes the escaping @yuyichao mentions).

---

_[View the full topic](https://discourse.julialang.org/t/include-a-script-from-external-file-in-different-scopes/1431)._
