Yes, the `1..9//2` communicates intention a little better than `a..b..c`
IMO.

Amos King, CEO

  <https://twitter.com/binarynoggin>
<https://www.facebook.com/BinaryNoggin/>
<https://www.instagram.com/binarynoggin/>
<https://www.linkedin.com/company/binary-noggin>

573-263-2278 a...@binarynoggin.com



On Mon, Mar 22, 2021 at 9:05 AM José Valim <jose.va...@dashbit.co> wrote:

>
>
>> 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 elixir-lang-core+unsubscr...@googlegroups.com.
> 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
> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JNXVDdJG%3DJ2MuiiN9%2BxHNUm58%2Bi%3DAbPygGkZm6sZ4jEA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/CAJr6D4Trei49Sigy0Eb-i4Q60_C4MVHUz-gf7LP77btfjBzEqQ%40mail.gmail.com.

Reply via email to