>
> Also, it’s a stretch, but it’s possible that a sloppy programmer separates
> these expressions, say by inserting a multiline comment, a typespec, or
> even something completely unrelated. Then it becomes harder to spot the
> complete specification of the struct.
>

Sloppy programmers will break all kinds of code. I generally really dislike
the sloppy programmer argument. Do we really want to guide our decisions
based on programmers that are sloppy?


> Say I want to move the struct to another module, I have to pay attention
> to move all three expressions (which might be separated by some other not
> necessarily struct related stuff). Or say in my macro which defines a
> struct, I want to prevent some option (e.g. require).
>

If you are moving code around, you always need to pay attention. :) What if
you are defining the struct like this:

if some_condition? do
  ... some code ...
  defstruct
else

  defstruct

end


If you get the first defstruct and ignore the rest... it will be wrong.

In contrast, having these macros accept valid options as arguments allows
> us to specify the struct in a single expression (which IMO reads nicer). It
> makes the interface more explicit about what’s accepted
>

This is, however, a good argument. If someone makes a typo or provide an
invalid option, it is easy to check with options, but not possible with
module attributes.

-- 
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%2BZk7uxTqpiVF%3DaODSBc%3DbNVWwQG9sV5MS_CCTZo1fD%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to