I'm quite new to Elixir, maybe I'm talking bullshit, but this looks to me
almost like a guard clause for the struct. Can't make the expressions on
guard clauses or match available somehow to each field?

On Wed, May 25, 2016 at 7:06 PM José Valim <[email protected]>
wrote:

> All other things being equal or very similar, I think the interface which
>> prevents sloppiness is better.
>>
>
> Except they are not equal and similar. One provides composability exactly
> because it is less restrictive. The other provides better feedback for
> being more restrictive with checking of options and less composable. We can
> make both assessments without bringing the sloppy programmer into the
> discussion.
>
>
>> It will break on compile, hinting me that I didn’t move the complete
>> code. Yes, I need to pay attention, but compiler has my back.
>>
>
> Not necessarily?
>
>     if some_option? do
>       # ...
>       defstruct foo: nil
>     else
>       defstruct foo: nil, bar: :baz
>     end
>
>
>> The latter approach means I have to know the semantics of @derive,
>> @require and defstruct/defexception/schema, to know that these things tie
>> together.
>>
>
> In both cases you need to understand the semantics of derive and require.
> For module attributes though, you do need to know how these things tie in
> together. It is the trade-off between restrictive and composable.
>
>
> --
> 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/CAGnRm4%2BicfA9Z%3DesQ%3Dw08XmtD_LvQKF2f4%3DEYx_N96fhL8FB5g%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4%2BicfA9Z%3DesQ%3Dw08XmtD_LvQKF2f4%3DEYx_N96fhL8FB5g%40mail.gmail.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/CACh1tgGtqEh4e5pCmtQawyqgWCqMvfBB6r0%3DCMv3n0qA9jU-dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to