Re: [elixir-core:9879] Proposal: Kernel.boolean/1

2020-12-25 Thread eksperimental
This will work: defguard to_boolean(term) when term not in [false, nil] On Wed, 23 Dec 2020 15:02:43 -0500 Austin Ziegler wrote: > It would be easy enough to provide this as a predicate in your own > code if that’s your style preference > > ```elixir > def boolean(falsy) when falsy in

Re: [elixir-core:9879] import a function having default values: we must specify each arity used

2020-12-25 Thread thojan...@gmail.com
> e.g if you have a function with the same name but one less argument That can actually also be considered as a function with default values (and in the end, default values generate such functions with different arities). If not then I think it's a code smell and the function needs to be

Re: [elixir-core:9876] import a function having default values: we must specify each arity used

2020-12-25 Thread Zach Daniel
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 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

Re: [elixir-core:9876] import a function having default values: we must specify each arity used

2020-12-25 Thread Zach Daniel
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 wrote: > Say function `foo` has multiple

[elixir-core:9876] import a function having default values: we must specify each arity used

2020-12-25 Thread thojan...@gmail.com
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