IEx c/0 to recompile file from command line

95 views
Skip to first unread message

Felix Bünemann

unread,
Aug 1, 2015, 5:37:22 PM8/1/15
to elixir-lang-core
Hello,

I'm currently learning Elixir, so I#m working with lot's of small .exs files, which I usually start with iex foo.exs.

It would be nice if there was a c/0 (or maybe r/0) function that recompiled the files passed on the command line, so I wouldn't need to re-type the filename with c/1 or restart iex.

Example:
iex foo.exs
iex>c
[Foo]

Regards,
  Felix

José Valim

unread,
Aug 2, 2015, 3:21:24 AM8/2/15
to elixir-l...@googlegroups.com
We support a list to be passed to c/1. So we recommend you to just keep a list around, and pass it every time you want to compile everything. We had something like you proposed but it ended-up just causing confusion. Another idea is to support directories, so you could keep all of them in a directory and just compile it.



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-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/fce061e6-cab4-458e-a6cc-0ee095ee0a26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jim Freeze

unread,
Aug 2, 2015, 3:53:23 PM8/2/15
to elixir-l...@googlegroups.com
You could add something like the following to your ~/.iex file to create a list of local script files:

local_scripts = :os.cmd('ls *.exs') |> to_string |> String.split(~r{\n}) |> Enum.reject(fn(e) -> e == "" end)


For more options, visit https://groups.google.com/d/optout.



--
Dr. Jim Freeze, Ph.D.

Felix Bünemann

unread,
Aug 2, 2015, 10:20:11 PM8/2/15
to elixir-lang-core
Hello Jim,


Am Sonntag, 2. August 2015 21:53:23 UTC+2 schrieb Jim Freeze:
You could add something like the following to your ~/.iex file to create a list of local script files:

local_scripts = :os.cmd('ls *.exs') |> to_string |> String.split(~r{\n}) |> Enum.reject(fn(e) -> e == "" end)

 I think you misunderstood what I'm tying to do. I don't want to recompile every exs in the current directory, I only want to recompile the exs I passed as the first argument to iex. Eg. if I call iex foo.exs, then c/0 would recompile foo.exs.

This would be easier to achieve if System.argv contained the filename passed, like for example in ruby.


On Sun, Aug 2, 2015 at 2:21 AM, José Valim <jose....@plataformatec.com.br> wrote:
We support a list to be passed to c/1. So we recommend you to just keep a list around, and pass it every time you want to compile everything. We had something like you proposed but it ended-up just causing confusion. Another idea is to support directories, so you could keep all of them in a directory and just compile it.



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

On Sat, Aug 1, 2015 at 11:37 PM, Felix Bünemann <felix.b...@gmail.com> wrote:
Hello,

I'm currently learning Elixir, so I#m working with lot's of small .exs files, which I usually start with iex foo.exs.

It would be nice if there was a c/0 (or maybe r/0) function that recompiled the files passed on the command line, so I wouldn't need to re-type the filename with c/1 or restart iex.

Example:
iex foo.exs
iex>c
[Foo]

Regards,
  Felix
--

Ed W

unread,
Aug 3, 2015, 7:52:42 AM8/3/15
to elixir-l...@googlegroups.com
On 03/08/2015 03:20, Felix Bünemann wrote:

> This would be easier to achieve if System.argv contained the filename
> passed, like for example in ruby.

This is probably the real feature request to make? (ie how to access
the command line parameters used to initiate iex)

Ed W



Jim Freeze

unread,
Aug 3, 2015, 11:26:25 AM8/3/15
to elixir-l...@googlegroups.com
Hi, Felix.

Oh, I see. That's a very good feature request.

Jim


--
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.

For more options, visit https://groups.google.com/d/optout.

Alexei Sholik

unread,
Aug 3, 2015, 3:17:05 PM8/3/15
to elixir-lang-core
You can get to the raw arguments using :init.get_plain_arguments. Although I agree that there could be a way to get the raw arguments passed to an Elixir program like iex or mix instead of the full invocation of erl that :init.get_plain_arguments returns.

--
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.
Reply all
Reply to author
Forward
0 new messages