[squeak-dev] FormInspector, or also: Text>>#= and its consequences

karl ramberg karlramberg at gmail.com
Thu Jan 12 05:46:07 UTC 2023


On Thu, Jan 12, 2023 at 12:00 AM Chris Muller <asqueaker at gmail.com> wrote:

> Since 2004, the test suite for Ma Object Serializer utilizes an abstract
> any-Object-comparison, and has worked really well.  This shows enough about
> how it does it -- basically brute force.
>
> [image: comparing-object-equivalence.png]
>
> The above is the abstract equivalence test implementation on Object which,
> yes, a lot of classes have to override.  But, it's not hard.
> Intimidation by the implementation should not be the (or, even a) deciding
> factor about whether Text equivalence should honor attributes.
>
> Re: copying -- there is no veryVeryDeepCopy, and there's nothing wrong
> with having all of #shallowCopy, #copy, #deepCopy vs. #veryDeepCopy.  The
> former is part of the Smalltalk language that generally goes +1 level
> deeper than regular #copy, whereas #veryDeepCopy is used for the Prototype
> design pattern, which is the fundamental design property of Morphic.
>

I'm with you here, there is nothing wrong with these copy methods. I just
point out that you have to be very cautious of your intentions when you use
them.

Best,
Karl


>  - Chris
>
> On Wed, Jan 11, 2023 at 7:37 AM Taeumel, Marcel <Marcel.Taeumel at hpi.de>
> wrote:
>
>> Hi Christoph --
>>
>> At this point, let's not fiddle with Text >> #=.
>>
>> I think that comparing sets of attributes with each other can be as
>> tricky as comparing morphs, unless you restrict yourself to very simple
>> emphasis (bold/italic/...).
>>
>> Identity-vs-state will bite you for "non-literal" attributes:
>> - PluggableTextAttribute (i.e., compiled code, bindings, complex objects,
>> ...)
>> - TextFontReference (i.e., various font properties, form-set fonts, pixel
>> comparison?, ...)
>> - TextAnchor (i.e., morphs ...)
>>
>> Thus, the very mechanism of text properties is so flexible that
>> implementing a useful comparison should be done on a case-by-case basis.
>> For example, compare #runs if necessary and sufficient, as suggested in the
>> comment in #=.
>>
>> Just comparing the identity of text attributes is not worth breaking
>> backwards compatibility.
>>
>> Best,
>> Marcel
>>
>> Am 16.09.2020 16:44:07 schrieb Thiede, Christoph <
>> christoph.thiede at student.hpi.uni-potsdam.de>:
>>
>> Hi Levente,
>>
>>
>> hm, I think #= should be always commutative and transitive, everything
>> else is at least confusing ...
>>
>>
>> Can't we move that "attribute invariant" comparison rather to something
>> like Text >> #sameAs:?
>>
>>
>> Best,
>>
>> Christoph
>> ------------------------------
>> *Von:* Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im
>> Auftrag von Levente Uzonyi <leves at caesar.elte.hu>
>> *Gesendet:* Mittwoch, 16. September 2020 15:00:28
>> *An:* The general-purpose Squeak developers list
>> *Betreff:* Re: [squeak-dev] FormInspector, or also: Text>>#= and its
>> consequences
>>
>> Hi Christoph,
>>
>>
>> On Wed, 16 Sep 2020, Thiede, Christoph wrote:
>>
>> >
>> > Interesting, I would not have assumed that this would be only about
>> performance, sounded like a more profound design decision to me.
>>
>> If you have a look at the comment of Text >> #=, you'll find that it's a
>> design decision (no reasoning though):
>>
>> = other
>>          "Am I equal to the other Text or String?
>>          ***** Warning ***** Two Texts are considered equal if they have
>> the same characters in them.  They might have completely different
>> emphasis, fonts, sizes, text actions, or embedded morphs.  If you need to
>> find out if one is a true copy of the other, you must do (text1 = text2
>> and: [text1 runs = text2 runs])."
>>
>>
>> Though equality with Strings is not symmetric;
>>
>> 'foo' asText = 'foo'. "==> true"
>> 'foo' = 'foo' asText. "==> false"
>>
>> I don't know what relies on Text-String equality, but probably many
>> things
>> assume that Texts and Strings are somewhat interchangable (remember when
>> you changed SHParserST80 >> #initializeVariablesFromContext, and Shout
>> ran
>> into errors because it expected source to be a String but got a Text?)
>>
>> You can't keep equality with Strings if you change #= because you'll lose
>> transitivity:
>>
>> 'foo' asText allBold = 'foo'. "==> true"
>> 'foo' asText = 'foo'. "==> true"
>> 'foo' asText allBold = 'foo' asText "==> false"
>>
>>
>> Should you decide to change #=, remember to change #hash as well, and
>> rehash all hashed collections with text keys.
>>
>>
>> Levente
>>
>> >
>> >
>> > If no one sees a problem in changing this behavior, I can try my luck.
>> :-)
>> >
>> >
>> > Best,
>> >
>> > Christoph
>> >
>> >
>> __________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________
>> > Von: Squeak-dev <squeak-dev-bounces at lists.squeakfoundation.org> im
>> Auftrag von Taeumel, Marcel
>> > Gesendet: Dienstag, 15. September 2020 16:42:11
>> > An: squeak-dev
>> > Betreff: Re: [squeak-dev] FormInspector, or also: Text>>#= and its
>> consequences
>> > Hi Christoph.
>> > Performance. Change it, bench it, post the results here. :-) Please
>> specify you machine and try it on a slow RaspPi, too.
>> >
>> > Best,
>> > Marcel
>> >
>> >       Am 10.09.2020 20:32:34 schrieb Thiede, Christoph <
>> christoph.thiede at student.hpi.uni-potsdam.de>:
>> >
>> >       Hi all,
>> >
>> >
>> >       is there any old thread about the design discussion of how
>> Text>>#= works? (It does not consider attributes for quality.) Has this
>> decision ever been questioned?
>> >
>> >
>> >       Naively and without an overview of any existing components that
>> could rely on this implementation, I would like to question it.
>> >
>> >       Why should 'foo' asText allBold be equal to 'foo' asText
>> addAttribute: TextURL new? With the same logic, we could also say that two
>> dictionaries are equal iff they have got the same keys ...
>> >
>> >
>> >       There is even a concrete client in the Trunk suffering from this
>> design decision: Marcel's new FormInspector (and analogously,
>> MorphInspector). It uses
>> >
>> >       TextFontReference with a FormSetFont to display a screenshot
>> right in the inspector pane. Unfortunately, the pane is never updated
>> automatically because even if the screenshot changes, the text morph thinks
>> the old text would equal the new one. I'd like to fix that without hacking
>> any workaround into
>> >       the inspectors.
>> > Even though this inspector implementation is a bit unusual, in my
>> opinion, it shows that the current Text >> #= implementation might not be a
>> perfect solution.
>> >
>> > I'm looking forward to your opinions.
>> >
>> > Best,
>> > Christoph
>> >
>> >
>> >
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230112/d43d2410/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: comparing-object-equivalence.png
Type: image/png
Size: 186694 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230112/d43d2410/attachment-0001.png>


More information about the Squeak-dev mailing list