I’m personally in favor of keeping the syntax. My main reasons are from a human code reading perspective and the way i like to structure my code. (A lot of these are personal opinions)
For instance, to me, I like it when the code has a clear distinction between Map and Struct (I know that structs are maps in the end but I think from a code organization point of view, if we provide a way to define concrete structures, it makes sense to have them distinguishable from maps).
I see this being exactly like how Erlang works with Records. Records are just tuples in the end, but it makes sense to have the #User{email = email} syntax in order to provide the distinction between regular tuples.
Where I see the differences
Map:
- Can have whatever key in it
- Is used as a variable and extensible data structure
- Updated and accessed using
Map.*functions.
Struct:
- Static map, fields should never be added nor removed.
- Is used to represent a concrete, reusable data structure.
- Provide compile time safety on field presence
- Updated and accessed through operators (
|for updating and.for accessing).
From a code reading perspective, seeing Map.put(data, :key, value) gives me clear indication that data is a Map (not a struct). And seeing %URI{data | path: path} gives me a clear indication that I’m working on a URI struct. Seeing %{data | key: value} has ambiguity, it tells me "I’m updating something that is at least a map with an enforced :key key, is it a struct?, I cannot tell, I need to read the surrounding code. I agree though, that in a perfect world, functions are kept short where variables are referenced closed to other, but not everyone works the same.
(I’m not saying everyone should follow this philosophy but over time it has proven a huge maintainability factor in the way I write my applications).
I personally only see benefits in keeping it especially if it comes with a “You must pattern match beforehand” warning if you didn’t, this seems to me like the best of both worlds. It doesn’t force anyone to use if you don’t but if like me you like it, you also get a reminder to tell you, for case where you didn’t, to pattern match. I’d be more in favor of a credo rule for those who wanna apply this strictly
But my main question would be, what is the gain of completely deprecating it? I understand the idea to promote the pattern match but bringing the warning feels quite sufficient for me to solve that problem.






















