Yeah. Let me summarize:
- Often engineers do
%Struct{}for creating a new instance of a struct by default. There is no established tradition to create factory functions like in Golang. - Elixir allows to set only “static” defaults. So
%Struct{}already has some implicitness, but at least it is “idempotent” after compilation. - For defining a dynamic default each place where
%Struct{},struct(...), etc is used should be refactored.- In big codebases it can lead to inadequately expensive refactoring for just introducing a mere dynamic default.
- creation of a struct can be inside library code so you may be not able to inject default value at all.
- Cultural problem: libraries repeat “no dynamic defaults” restriction that does not makes developers life easier, usually opposite.
- Such limitation is uncommon in other popular languages I can recall.
Original proposal solves mentioned problems, but breaks %Struct{} == %Struct{} behavior. But without breaking it we cannot make %Struct{} respect dynamic defaults. And without this we cannot make adding dynamic defaults cheap in big codebases.
Might be loosing this behavior is acceptable sacrifice? Or we’re missing some smart move here?


















