A minor point, but I can't pass up the opportunity to reference Perl:
The ~w goes back further than even Ruby.  Perl (which was really Ruby
v0.1 ;-)  has qw// which "quotes words" in a similar way.  And I'm
sure Perl probably got it from sed or awk or somewhere.

A warning her isn't a bad idea, but I'm sure there's some annoying
edge case that would make coding it tricky.  Since when has that ever
stopped us?!? ;-)

-Augie

On Wed, Jun 22, 2016 at 8:06 AM, Onorio Catenacci <[email protected]> wrote:
> Hi all,
>
> Consider the following code:
>
> defmodule WSigilTest do
>   def t1 do
>     ~w(abc def ghi)
>   end
>
>   def t2 do
>     ~w(abc, def, ghi)
>   end
> end
>
> I was working with some Ecto code and had a changeset and rather foolishly
> used the form in the function t2 rather than the form in t1.  In case anyone
> else isn't clear on the difference:
>
> iex(3)> WSigilTest.t1
> WSigilTest.t1
> ["abc", "def", "ghi"]
> iex(4)> WSigilTest.t2
> WSigilTest.t2
> ["abc,", "def,", "ghi"]
>
> Notice the comma appended to each string in t2?  I didn't. :)
>
> I realize that we need to be careful of syntax, of course, but would it be
> possible to maybe add a compiler warning when someone includes commas in the
> string passed to ~w?  I would be glad to see about creating a PR for this
> but I first wanted to see if there's even any interest in the idea.  Maybe
> it's just me since I don't have a background in Ruby; I guess the ~w comes
> pretty much straight from Ruby.
>
> Please let me know your thoughts on this.
>
> --
> Onorio
>
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/06431f8a-387c-48a1-9156-a1a33e1dc0d3%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CABYU8zjXJiEpOrREk_MrJAkL9Opa9jHts9r%3DmELEsFxL%3DQAEfA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to