News for hackers. Stuff that matters.
Re:Has UML died without anyone noticing? by wwwwewwww on Monday April 26, 2021 @03:04AM (#26940034)
Why would you need a copy method for an immutable record?
Re:Has UML died without anyone noticing? by etripe on Monday April 26, 2021 @06:33AM (#26941097)
When applying events, for instance. In F#, you could do:

  match msg with

  | IncreaseCounter cnt ->
   { model with Count = model.Count + cnt }

  | DecreaseCounter cnt ->
   { model with Count = model.Count - cnt }

  | ResetCounter ->
   { model with Count = 0 }

  | ChangeRubric name ->
   { model with Rubric = name, Count = 0 }
The "with" says: copy the original record by value, but change these fields. For completeness' sake: F# also has implicit returns, so the bit between brackets is the function's return value.
Re:Has UML died without anyone noticing? by TomSwirly on Monday April 26, 2021 @03:39AM (#26940243)
Python's dataclasses have a "make a copy with these fields changed" function that's rippingly useful for immutable records.