[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Say No to global-by-default
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Wed, 4 Jul 2018 17:56:35 -0300
On Wed, Jul 4, 2018 at 5:43 PM, Alexander Mokrushyn
<codeservice@gmail.com> wrote:
> Would be nice have conception of namespace. Namespace always global, in
> every programming language.
>
> Code can look like:
>
> namespace MyNamespace
> a = 1
>
> function fn1()
> end
> end
>
> and if I load code as package, I can access to "a" or function:
>
> print(MyNamespace.a)
> MyNamespace.fn1()
You can already do exactly that with _ENV:
MyNamespace = {}
do
_ENV = MyNamespace
...
end