Skip to content
This repository was archived by the owner on Feb 4, 2021. It is now read-only.

Enable functional-like behavior with 'persistent' interfaces #19

Open
sdboyer opened this issue Apr 24, 2014 · 1 comment
Open

Enable functional-like behavior with 'persistent' interfaces #19

sdboyer opened this issue Apr 24, 2014 · 1 comment
Assignees

Comments

@sdboyer
Copy link
Owner

sdboyer commented Apr 24, 2014

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.

@sdboyer sdboyer self-assigned this Apr 24, 2014
@sdboyer sdboyer changed the title Enable functional-like behavior with mutables by having the methods return 'self' Enable functional-like behavior with 'persistent' interfaces Apr 28, 2014
@sdboyer
Copy link
Owner Author

sdboyer commented Apr 28, 2014

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant