Re:Immer is a library of persistent and immutable data struc...
by agumonkey on Thursday September 12, 2019 @03:40AM
(#20948980)
what would be a good word for this ? recreate ? recompute ? with_new ?
[ Parent
| on HN ]
Re:Immer is a library of persistent and immutable data struc...
by ScottBurson on Thursday September 12, 2019 @05:07AM
(#20949488)
In general, I think verbs should be avoided, when possible, as names of functional operations. For instance, in Java, 'BigInteger.add' should have been 'plus'. Compare:
x.add(y);
x.plus(y);
People have been known to write the first one expecting 'x' to be updated. With the second, I think it's clearer that it's a value that needs to be assigned to a variable.For the operation in question here, I suggest 'with'. This is what I have used in my own functional collections libraries; I think it originated in SETL.
Re:Immer is a library of persistent and immutable data struc...
by skohan on Thursday September 12, 2019 @06:31AM
(#20949905)
I am a fan of nouns(or gerunds) for pure functions, and verbs for mutating functions. I.e:
x.add(y); // x now equals x + y
x.adding(y); // returns x + y without mutating x
Re:Immer is a library of persistent and immutable data struc...
by masklinn on Thursday September 12, 2019 @04:05AM
(#20949124)
Clojure as `(assoc col key val)` and `(update col key fn)` though I don't know that the naming scheme is significantly clearer.
Re:Immer is a library of persistent and immutable data struc...
by physicsyogi on Thursday September 12, 2019 @04:00AM
(#20949103)
I'd probably be happy with "update", which is similar to Clojure's API for its persistent vector and map.