Hi José the main reason I see is merely estetic and is to avoid retyping 
the "@enforced_keys" in "defstruct" but you're right: I have not measured 
the impact on the ecosystem. For that reason, as Louis said,  it could 
better fit in a library.

Thank you for your feedback guys :)

El domingo, 24 de diciembre de 2017, 16:59:21 (UTC-5), Juan Jose Lopez 
Tugores escribió:
>
> For example instead of
>
> defmodule Foo do
>
>     @enforce_keys [:foo1, :foo2] 
>
>     defstruct [:foo1, :foo2, :foo3] 
>
>  end
>
>
> I write
>
> defmodule Foo do 
>
>     @required_keys [:foo1, :foo2] 
>
>     @optional_keys [:foo3] 
>
>     @enforce_keys @required_keys 
>
>     defstruct @required_keys ++ @optional_keys 
>
>  end
>
>
> But I think it could better be
>  
>
>> defmodule Foo do 
>
>     defrequired [:foo1, :foo2]
>
>     defoptional [:foo3] 
>
>  end 
>
>

-- 
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/6f36a76d-dc7e-4475-ae62-76c8c3cf292a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to