1688 shaares
869 private links
869 private links
Nice write up. Aside from these mentioned, I also wanted to point out a few problems about Protocols.
- the implementation on struct is fine, but implementations on primitive types are very different and sometimes awkward
- the first argument is forced to be the type that implements the protocol, making it difficult to define abstract methods on, for example, a set of values
- there is no concept of associated type, associated constant,
- the role of protocols mostly overlaps with a
@behaviour
but a behaviour is more flexible
And here are more places I'd like to see improvements (some pointed out in the article, too):
- the lack of simpler struct construction/deconstruction syntax sugar, forcing everyone to write code like
%{a_long_property: a_long_property}
repeatedly - the lack of early return. the design of
with
discards the information about the mismatching branch. Ecto.Multi
is not composable (I tried to fix it via https://github.com/shouya/ecto-tx)