This is also by design and mentioned in the docs. Except is always
exclusive on a previously defined import, if there is no import, then we
take all macros and functions.

Imagine you "import Foo.Bar, only: ..." and then in some part of your code
you have a conflict and would you like to remove that conflict in
particular. If except brought everything back, it would be confusing
behaviour and the only alternative would be for you to repeat the whole
list in :only except for the element you want removed.

*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*

On Sat, Sep 23, 2017 at 2:29 PM, Ben Wilson <[email protected]> wrote:

> Setting aside whether or not the existing functionality is intuitive or
> not, this isn't actually a proposal. You aren't suggesting an alternative.
>
> On Thursday, September 21, 2017 at 10:17:12 AM UTC-4, Krzysztof Wende
> wrote:
>>
>> Right now when we import a module A
>>
>> defmodule CurrentA do
>>   def public1, do: 1
>>   def public2, do: 2
>>   def public3, do: 3
>> end
>>
>>
>> defmodule CurrentA do
>>   import CurrentA, only: [public1: 0]
>>   import CurrentA
>>
>>   def test, do: public2() # No problem whatsoever
>> end
>>
>> But whenever we add `except` to it
>>
>> defmodule CurrentA do
>>   def public1, do: 1
>>   def public2, do: 2
>>   def public3, do: 3
>> end
>>
>>
>> defmodule CurrentA do
>>   import CurrentA, only: [public1: 0]
>>   import CurrentA, except: [public3: 0]
>>
>>   def test, do: public2() # undefined function public2/0
>> end
>>
>> We get an error of inexistent function. For me it feels super
>> counter-intuitive.
>>
>> Thoughts?
>> Cheers,
>> Krzysztof
>>
> --
> 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/7f1e33c3-21d4-4c0f-b176-
> bdcc1fe35f81%40googlegroups.com
> <https://groups.google.com/d/msgid/elixir-lang-core/7f1e33c3-21d4-4c0f-b176-bdcc1fe35f81%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/CAGnRm4LBVGMRPypUWvM-e%3DCHhaOjbAkKZNB_vz4Oo%3D4%2BqObUhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to