Sorry, meant to say “in being able to say only import this *function*”, not
story :)

On Fri, Dec 25, 2020 at 5:42 PM Zach Daniel <zachary.s.dan...@gmail.com>
wrote:

> There are theoretical name conflicts from not being able to say “only
> import this story”  (e.g if you have a function with the same name but one
> less argument) what about import Mod, only: [func: 1..3]?
>
> On Fri, Dec 25, 2020 at 5:36 PM thojan...@gmail.com <
> thojansse...@gmail.com> wrote:
>
>> Say function `foo` has multiple default values (two required args, two
>> with defaults). When importing, we must specify each arity that is used in
>> the calling code, e.g.
>>
>> ```
>> import Foo, only: [foo: 2, foo: 3, foo: 4]
>>
>> foo(1, 2)
>> foo(1, 2, 3)
>> foo(1, 2, 3, 4)
>> ```
>>
>> I expected that I could only import `foo/4`, and be able to call `foo`
>> with only two arguments and three arguments. Why? Because there is no use
>> case to force an imported function to be used only with a specific arity.
>> That would even be a code smell.
>>
>> Could we "generate" [foo: 2, foo: 3]` in addition to `[foo: 4]` to
>> support the call using its default values?
>>
>>
>> --
>> 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/28497895-3278-4de0-8423-99f9b9230597n%40googlegroups.com
>> <https://groups.google.com/d/msgid/elixir-lang-core/28497895-3278-4de0-8423-99f9b9230597n%40googlegroups.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/CAK-yb0B_Zi4m9sZfmGs_Lw51HOhiWz6KirDrZj1MGgM9s_Hh%3DQ%40mail.gmail.com.

Reply via email to