If you want composability how about: require_keys [:a, :b], in: defstruct [:a, :b, :c]
require_keys [:message], in: defexception ... Also repeating mandatory keys with some default values seems quite annoying. On 26 May 2016 3:06:25 AM AEST, "José Valim" <jose.va...@plataformatec.com.br> 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 elixir-lang-core+unsubscr...@googlegroups.com. >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. >For more options, visit https://groups.google.com/d/optout. -- Best wishes, Dmitry Belyaev -- 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/196BA74C-E4AC-4410-AFFA-C6F6D2BA00A2%40gmail.com. For more options, visit https://groups.google.com/d/optout.