[Cuis-dev] Immutability package

Hernan Wilkinson hernan.wilkinson at 10pines.com
Fri May 8 08:00:55 PDT 2020


What is Rope? do you have a link to the definition/paper?

Thanks!

On Fri, May 8, 2020 at 11:48 AM <ken.dickey at whidbey.com> wrote:

> On 2020-05-08 06:15, Juan Vuletich via Cuis-dev wrote:
>
> Something else that would be great is to gradually make Strings
> immutable. That would allow us to replace String with Rope if desired.
>
> Actually, Ropes are (or are supposed to be) immutable.
>
> Strings to Ropes is more of a style change.
>
> The main difference is that operations on ropes (e.g. #at:put:) return a
> _new_ rope, where Strings are mutated in place.  So the first change
> would be ensuring all String mutators return a reference to the mutated
> String instance and all senders use the latest reference.
>
> This can make Undo easier.  Just chain/push ref to previous ropes.  Undo
> is pop last & redraw.
>
> If we made Text operations functional as well, TextEditor should have a
> simplified Undo.
>
> Different costs.
>
> Note that I did Ropes as preparation for using them in Unicode, where
> UniChars can be 1, 2, or 4 bytes.  When inserting a Chinese character in
> an ASCII text string in Squeak, the Chinese character is a "wide"
> character, so Squeak changes the entire String to *all* wide characters,
> doubling its storage size.  UniStrings are Ropes, so adding a Chinese
> UniChar just keeps a reference to the old Rope and remembers where the
> new char is for #at: and #at:put: .  This memory is _much_ cheaper than
> doubling storage for the large strings typically used in text editing.
>
> Details in EnhancedText repository.
>
> Cheer,
> -KenD
>


-- 

*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20200508/abd92b54/attachment.htm>


More information about the Cuis-dev mailing list