--
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/263d7c39-a32b-4294-93d8-40f248c9b3c8n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JX4NE1yWH1G5L_DjF18v8zejF0%2BSkb_oz%3DPiUHM8Mz1w%40mail.gmail.com.
Unfortunately this can’t be done automatically since it has subtle semantic differences. In particular Enum.count/1 (or length/1) not only traverses the list to count its size, but also verifies it’s a proper list raising an exception for improper lists. The difference could be seen for value like:
[1, 2, 3 | :invalid]
Calling length/1 or Enum.count/1 on this raises. If compiler did the optimisation you propose, for something like length(list) > 0, it wouldn’t fully traverse the list and wouldn’t raise. Thus such an optimisation is not possible in the general case.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-yb0BBGCrgbZamFs%2BeqLUis6mFQgvUHkKK1htSN5rDDWwMRQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/DB7PR07MB3899C92933992464F17898E1FAF20%40DB7PR07MB3899.eurprd07.prod.outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-yb0BO2QESHcaL7-svOoAGqvr6hJi%3D8AHFqi-qNZdoFEMMwA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5fc98859.1c69fb81.3cf33.11a4SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAK-yb0AfjLS-vef8u9EWpuQ3tHVaXXfvAF9QMu%2B9hin7WjoNQA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LNUYuR%2BztiJ5p3viSEd-Tj6CbptUvyt9CrGigRtKjTMQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/1B141347-7013-4C56-BCFB-E1A1A4430422%40brex.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2B7zkrwsD6ZnsC0TwqZnWKepEPw3RqaQXJ-6QCffp6e-Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/9938fb50-2325-4239-b3f6-7aa66a236d9dn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/5bcfe253-8f5d-4332-a39a-86dd60f73635n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAJMspK0-yH297R8u8wmdd871gJUVOoxP2osjHsWZ-oBPu5x_2w%40mail.gmail.com.