Today, I reviewed some code by a new Elm programmer that did something like:
{ myRecord
| field = f myRecord.field
, field = g myRecord.field
}
The intent was to apply f
to myRecord.field
and then g
to the result, but of course that’s not what happens, and unless I’m missing something the first update to field
can’t ever have any effect on the outcome of the program (unless it goes into an infinite loop or divides by zero or something).
Since it’s never a good idea to update the same field twice, it’s possible to get yourself in trouble by doing it, and it’s trivial to catch at compile time, double-field-updates seem like a good candidate for making illegal in the next Elm release.
Does that seem reasonable to people?