# Local using declaration

**URL:** <https://discourse.julialang.org/t/local-using-declaration/23615>\
**Category:** Internals & Design\
**Tags:** proposal\
**Created:** [April 28, 2019, 8:33am UTC](https://discourse.julialang.org/t/local-using-declaration/23615 "2019-04-28T08:33:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kim366](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kim366/32/5756_2.png) [@kim366](https://discourse.julialang.org/u/kim366)\
**Post date:** [April 28, 2019, 8:33am UTC](https://discourse.julialang.org/t/local-using-declaration/23615/1 "2019-04-28T08:33:30Z")

</div>

In C++ you often do something like this:

```cpp
{
    using std::begin;
    using std::end;
    std::sort(begin(x), end(x));
}

```

In Julia, when you have

```nohighlight
let
    using .Iterators: take
    take([1, 2, 3], 2) |> collect
end

```

This will dump `take` into `Main` (“globbal namespace”) also outside of `let`, since `using` works on module scope.

I propose having a local using like in C++ that only imports symbols in the current scope (same lifetime as variables).

What do you think?

---

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [April 28, 2019, 8:36am UTC](https://discourse.julialang.org/t/local-using-declaration/23615/2 "2019-04-28T08:36:51Z")

</div>

In Julia you can do:

```julia
let
    take = Iterators.take
    take([1, 2, 3], 2) |> collect
end

```
