[Cuis] Ropes (functional strings)
Ken Dickey
Ken.Dickey at whidbey.com
Mon Feb 11 22:08:11 CST 2013
Juan wrote:
> Yesterday I played a bit to see how quickly the system would break if
> #at: and #at:put: were banned for Strings.
I did a simple, prototype implementation of Ropes, functional strings, for Cuis.
Ropes are _immutable_ (constant) strings, and #at:put: returns a new Rope. Internal data structures hide the details.
The basic idea is that I had a utf-8 Rope and #at:put: a utf-32 Chinese character into it, then we would NOT have to change the utf-8 part just because of one character. We could have separate 8/16/32 bit char-arrays supporting Unicode and do mix 'n match as we needed.
https://github.com/KenDickey/Cuis-Ropes
Invoking
Rope openTextEditor
brings up a simple text editor with a rope instead of a string.
This seems to work OK for me, but more knowledgeable people should take a look.
As this is a prototype, Rope>>doesNotUnderstand writes a message to the Transcript and re-sends it to its stringRepresentation.
So far, I have only seen sends to #encompassParagraph, which I don't yet understand and did not implement.
Anyway, feel free to take a look and let me know if you think it is useful.
Cheers,
-KenD
More information about the Cuis
mailing list