Changes to the struct update syntax

IMO I disagree that this reduces the surface area of Elixir, it increases it. As long as these are true:

  1. Structs are Maps
  2. Maps have an update syntax: %{var | ...pairs}
  3. Structs have a compiler-verification syntax: %module_name{...pairs}

Then I would expect rules 2 and 3 to compose: such that structs can use both update and compiler-verification syntaxes together (today, %module_name{var | ...pairs}). That is, it is a syntax that emerges logically and consistently from simpler syntax rules.

Having to remember that rules 2 and 3 are not compatible would add to the language surface area by requiring memorizing that as a new rule, even if the rule itself is not additive, but restrictive. As a new special-case to memorize in addition to the above 3 rules, it increases the surface area of the language.

From the compiler’s perspective, I can understand how it feels like a redundant construct, as it is a form that must be handled discretely. But to programmers and especially newcomers, I’d argue that it’s not a construct at all in their heads, simply the co-location of two simpler constructs, and therefore does not make sense to deprecate “as its own” syntactic form, even if the type system allows expressing the same checks in other ways.

22 Likes