[squeak-dev] String & Text

Jakob Reschke jakres+squeak at gmail.com
Mon Jul 18 08:53:54 UTC 2022


Am Mo., 18. Juli 2022 um 03:39 Uhr schrieb Chris Muller <asqueaker at gmail.com
>:

> *Text* is unique in the image from the aspect of it being the only class
> that is simultaneously a *byte* *and* *pointer* object.  Thanks to the
> magic of TextAnchor's, any character of a Text is allowed to be a pointer
> object.  It's implemented by (Character value: 1) being yet another special
> substitution performed dynamically during layout.
>

As I mentioned in my previous email, if the String methods were simply
pulled up, some of them would turn Texts to Strings in their answers. In
this case, the `Character startOfHeader` would remain in the string, but
the TextAnchor would, of course, be lost, and the attached object along
with it.

Either some selectors would be known to discard Text features, or Text
would have to refine them to preserve these features, or these methods
would need to be refactored to a more general (maybe less efficient?)
implementation that allows Text to preserve its features. In some cases
this could be as simple as using self class streamContents: instead of
String streamContents:, but it will certainly be more complicated in
other cases. So before drawing any conclusions, we need more thorough
analysis of the offending methods.

Some methods should probably simply not be pulled up. For example, I do not
see the usefulness of computing a CRC on a Text (ignoring its attributes),
converting one to a VM file path, or decoding a URL from one. But I suppose
one could also ask: why not if you can theoretically do these things with
sequences of characters...

PS. CompiledMethods are also a combination of bytes and pointers, and in
their case, even the VM treats them as such. Text on the other hand is not
strictly speaking a byte object, since the bytes or (words in WideString)
are in its string object. 🤓 But I got your point that Text embodies both
characters and other objects and may therefore have different requirements.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20220718/edb14516/attachment.html>


More information about the Squeak-dev mailing list