modules that are required automatically

46 views
Skip to first unread message

eksperimental

unread,
Sep 13, 2016, 12:41:06 AM9/13/16
to elixir-l...@googlegroups.com
I'm hacking Elixir core, and I haven't managed to find the code that makes some modules not to be
required in order to use them. Same as it happens with Enum for example.

Can anybody guide me in what's the procedure to achive this? since I'm trying to avoid "require
NewModule" from a macro I'm working on.

Thank you

José Valim

unread,
Sep 13, 2016, 2:39:46 AM9/13/16
to elixir-l...@googlegroups.com
You always need to require a module before using it. The only exception is the Kernel module.



José Valim
Skype: jv.ptec
Founder and Director of R&D


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20160913114058.0f10b282.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.

eksperimental

unread,
Sep 13, 2016, 8:55:05 AM9/13/16
to elixir-l...@googlegroups.com
Thank you José for your answer,
so why is so I don't need to require IO and Enum?

$ elixir -e "IO.inspect(Enum.at(1..5, 2))"
3


On Tue, 13 Sep 2016 08:39:24 +0200
José Valim <jose....@plataformatec.com.br> wrote:

> You always need to require a module before using it. The only exception is
> the Kernel module.
>
>
>
> *José Valim*
> www.plataformatec.com.br
> Skype: jv.ptec
> Founder and Director of R&D
>
> On Tue, Sep 13, 2016 at 6:40 AM, eksperimental <eksper...@autistici.org>
> wrote:
>
> > I'm hacking Elixir core, and I haven't managed to find the code that makes
> > some modules not to be
> > required in order to use them. Same as it happens with Enum for example.
> >
> > Can anybody guide me in what's the procedure to achive this? since I'm
> > trying to avoid "require
> > NewModule" from a macro I'm working on.
> >
> > Thank you
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "elixir-lang-core" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to elixir-lang-co...@googlegroups.com.

Louis Pilfold

unread,
Sep 13, 2016, 9:03:21 AM9/13/16
to elixir-l...@googlegroups.com
Functions do not need to be required, only macros :)

Cheers,
Louis

On 13 September 2016 at 13:54, eksperimental
> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/20160913195458.31cf0f06.eksperimental%40autistici.org.

Allen Madsen

unread,
Sep 13, 2016, 9:29:52 AM9/13/16
to elixir-l...@googlegroups.com
Both `import` and `use` will do the require for you.

See: http://elixir-lang.org/getting-started/alias-require-and-import.html

Until I read this, I also didn't understand why I didn't need to use
require everywhere.
Allen Madsen
http://www.allenmadsen.com
> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAM-pwt6Qh340ATYosvrNt%3DWNLCz36dyWYHer9m5dpkbxYS_gpg%40mail.gmail.com.

eksperimental

unread,
Sep 14, 2016, 12:23:28 PM9/14/16
to elixir-l...@googlegroups.com
It happened the same to me Allen,
Thanks Ĺouis for clarifying that.
Reply all
Reply to author
Forward
0 new messages