[Proposal] Format capture with sequencial params

30 views
Skip to first unread message

Glauber Campinho

unread,
Oct 21, 2017, 10:53:01 AM10/21/17
to elixir-l...@googlegroups.com
I was changing some code, removed all the extra params to the function and forgot to simplify the capture, so I notice that the formatter also don't care about it. So, I would like to add this rule, it feels way nicer to read and I didn't see anything about this case:

    assert_format "&foo(&1)", "&foo/1"
    assert_format "&foo(&1, &2, &3)", "&foo/3"

I would be happy to do it if people agree.

Cheers,
Glauber

José Valim

unread,
Oct 21, 2017, 2:50:16 PM10/21/17
to elixir-l...@googlegroups.com
Hi Glauber,

The formatter is not allowed to change the underlying AST. For example, someone could write a macro that interprets & in a completely different way than Elixir's, and if we rewrite that, we would break the user code.

To put it in other words, the formatter has no semantic understanding of the code.



José Valim
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/CACh1tgG03MUYHdMqS4ii4wtzeqUu6FwhRVKej5ecp1gYmA7tSw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Glauber Campinho

unread,
Oct 21, 2017, 9:01:30 PM10/21/17
to elixir-l...@googlegroups.com
Oh I get! Okay then :)

On Sat, Oct 21, 2017, 20:50 José Valim <jose....@gmail.com> wrote:
Hi Glauber,

The formatter is not allowed to change the underlying AST. For example, someone could write a macro that interprets & in a completely different way than Elixir's, and if we rewrite that, we would break the user code.

To put it in other words, the formatter has no semantic understanding of the code.



José Valim
Founder and 
Director of R&D

On Sat, Oct 21, 2017 at 4:52 PM, Glauber Campinho <ggcam...@gmail.com> wrote:
I was changing some code, removed all the extra params to the function and forgot to simplify the capture, so I notice that the formatter also don't care about it. So, I would like to add this rule, it feels way nicer to read and I didn't see anything about this case:

    assert_format "&foo(&1)", "&foo/1"
    assert_format "&foo(&1, &2, &3)", "&foo/3"

I would be happy to do it if people agree.

Cheers,
Glauber

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

--
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/CAGnRm4J2%2BaxT4mihA1JnAgS8WzA1_DWkFDTxF6D_7J%2Bur-1yVg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages