Good points, I will improve the docs.

Btw, h ../2 works for now.

I will investigate if it is possible to fix "Kernel...2" but it may not be
as it is being parsed as Kernel .../2 and not as Kernel. .. /2.



*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

On Mon, Dec 26, 2016 at 1:58 AM, miwee <[email protected]> wrote:

> agreed.
> Few fixes may help
> 1. The documentation https://hexdocs.pm/elixir/Kernel.html#../2 can
> mention about backward counting behavior, when end is less than start
> 2. probably iex has a bug,
> iex(41)> h Kernel.../2
> ** (SyntaxError) iex:41: syntax error before: '...'
>
>
> On Sunday, December 25, 2016 at 6:20:55 PM UTC+5:30, José Valim wrote:
>>
>> It is a known and documented behaviour. Even though it could be
>> surprising for some, we would need a very strong reason to remove it from
>> the language, and I don't think we have one here.
>>
>>
>>
>> *José Valim*
>> www.plataformatec.com.br
>> Skype: jv.ptec
>> Founder and Director of R&D
>>
>> On Sun, Dec 25, 2016 at 11:28 AM, miwee <[email protected]> wrote:
>>
>>> TLDR: it's a nit picking and may introduce breaking changes without
>>> possibly any significant gain, except conceptual clarity and explicitness.
>>>
>>> iex(27)> n = 4
>>> 4
>>> iex(28)> 1..n |> Enum.into([])
>>> [1, 2, 3, 4]
>>> iex(29)> n = 1
>>> 1
>>> iex(30)> 1..n |> Enum.into([])
>>> [1]
>>> iex(31)> n = 0
>>> 0
>>> iex(32)> 1..n |> Enum.into([])
>>> [1, 0]
>>>
>>> The result for n = 0, is little bit magical, as I was expecting it to
>>> return [], but instead it auto-magically detected that end is less than
>>> start and hence it counted decrementally. I think it creates confusion,
>>> particularly when both start and end are not constants like the above case
>>> given.
>>>
>>> So does it make sense to restrict the behavior of .. operator to always
>>> count incrementally. For the case of decremental counting Enum.reverse can
>>> be used. In that sense 1..4 |> Enum.reverse() is identical to present
>>> behaviour of 4..1
>>>
>>> --
>>> 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/ms
>>> gid/elixir-lang-core/da1cd897-1410-4237-b95f-04e61ec7bcfe%
>>> 40googlegroups.com
>>> <https://groups.google.com/d/msgid/elixir-lang-core/da1cd897-1410-4237-b95f-04e61ec7bcfe%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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/CAGnRm4%2BuD-8VJPTP_ojumPXZgNPnuQ%3D%2BTuhma7xBf%2BS4CB3RJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to