1. 4
  1.  

  2. 1

    There is also an ongoing conversation about this on the srfi-discuss mailing list where Marc Nieper-Wißkirch points out why he believes this would be a bad idea (at least, for Scheme and other dynamically typed languages).

    1. 1

      I agree that there’s no simple, clean way to retrofit this into Scheme. But I wouldn’t make a general statement about all dynamically typed languages. If your dynamically typed language represents all data as immutable values, then you can use linear update to efficiently implement data structure updates, if the system can prove that the underlying memory object that represents the value only has one reference.

    2. 1

      Swift’s class library uses the linear-updating pattern a lot. Since class instances are ref-counted, there’s a utility method that tells you if you have the only reference to an object. Then you can choose whether to mutate or copy it. Then the object is wrapped in a tiny struct that just points to it, giving value semantics.