Open sdboyer opened 10 years ago
on further reflection, it's really not possible to do this in a way that's fully consistent with the existing Mutable
interfaces; adding return values would introduce an inconsistency that should not be inflicted on client libs, as the return value from an imperative-style mutable would be the same pointer as the original method receiver, but the return value from a functional-style mutable would be a different pointer.
consequently, a Persistent
set of interfaces is a better approach; these would add the return values on methods of the same name as what's already on Mutable
. thus, it'd be impossible to implement both the persistent and mutable interfaces at the same time.
functional style dictates that all state mutations should return a new instance of the underlying datastructure (which can be accomplished by mapping into a tree somewhere). the mutable interfaces should be changed to accommodate this pattern (though not necessitate it) by adding return values that are of the interface mutator type.