> I still find the syntax to be confusing with the step as the last element.
> I really wish that we could do something like `a..b by: 3` but that comes
> with other implementation issues. I like the proposals using a different
> operator for the step. `a..b\\c`?
>

Unfortunately a..b\\c is ambiguous because \\ is used as default arguments.
So you could do "a..b\\1..3". It is semantically unambiguous in this case,
but definitely syntactically ambiguous.

Here are some approaches of what we could allow. I am considering they all
represent the range from 1 to 9 by 2 and from 9 to 1 by -1:

   - 1..2..9 and 9..-1..1 - as someone proposed, maybe having the step in
   the middle is clearer

   - 1..9//2 and 9..1//-1 - note // is generally ambiguous in Elixir
   because of the capture operator. So this will only work if ..// is defined
   as a ternary operator. This means we will likely introduce the atom :..//
   and the capture operator would be &..///3. I think those are acceptable
   trade-offs, but worth mentioning.

   - Combinations with \ and /:
   - 1..9/\2 and 9..1/\-1
      - 1..9*\2 and 9..1*\-1
      - 1..9\/2 and 9..1\/-1
      - 1..9*/2 and 9..1*/-1

      - 1..9^^2 and 9..1^^-2

To be honest, I like the first two. One nice bonus about 1..9//2 is because
we can actually think that it is cutting the number of elements in 2, by
some approximation. 1..8//1 has 8 elements. 1..8//2 has 4. :)

-- 
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/CAGnRm4JNXVDdJG%3DJ2MuiiN9%2BxHNUm58%2Bi%3DAbPygGkZm6sZ4jEA%40mail.gmail.com.

Reply via email to