[Cuis-dev] Preference>>accept: visitor is gone

Juan Vuletich JuanVuletich at zoho.com
Sat Jul 9 13:02:41 PDT 2022


Hi Hilaire,

On 7/9/2022 6:00 AM, Hilaire Fernandes via Cuis-dev wrote:
>
> Hi Juan,
>
> Since your update 5355 the accept: visitor is gone from the Preference 
> class.
>
> Although not used in the core image, it is needed to visit Preference 
> in third party application. I copy and paste it below so you merge it 
> back:
>
> Preference>>accept: aVisitor
>     | visitMethod |
>     self isTypeAClass
>         ifTrue: [ visitMethod _ ('visit', type name, 'Preference:') 
> asSymbol ]
>         ifFalse: [visitMethod _ ('visit', type species asString, 
> 'Preference:') asSymbol ].
>     ^ aVisitor perform: visitMethod with: self
>
>

Added it back. Apologies.

> Also I noted your edit of the type method:
>
> Preference>>type
>     (type inheritsFrom: CharacterSequence) ifTrue: [ type _ 
> CharacterSequence ].
>     ^ type
>
> It breaks the Preference behavior in DrGeo with my dedicated type 
> objects (DrGTypeArrow, DrGTypePointShape, etc.), all subclasses of an 
> Object. Indeed #inheritsFrom: is defined in Behavior not in Object.
>

I see. I pushed an update that does essentially the same, but should not 
break your code.

> I am wondering if it is needed because we all detect type?
>

People may set type String explicitly. Besides, many existing 
preferences have type String. That's why I also modified #type.

> Preference>>detectType: anObject
> "When the type is not provided, we can try to deduce it "
>
>     (anObject isKindOf: CharacterSequence) ifTrue: [ ^CharacterSequence ].
>     ^ anObject class name
>         caseOf: {
>             [#True] -> [Boolean].
>             [#False] -> [Boolean].
>             [#StrikeFont] -> [AbstractFont].
>             [#TrueTypeFont ] -> [AbstractFont]
>         }
>         otherwise: [anObject class]
>
> I understand these changes are related to your utf-8 work in progress.
>

Yes. Now, and Utf8String may appear anywhere a String was expected. They 
are fully polymorphic and this should not create any problems. But then, 
in all places (in _almost_ all places) where type checking or 
conversions is done, an Utf8String must be accepted.

BTW, the Utf8 stuff is mostly done. Only sorting (collation) needs a bit 
more work.

> Best
>
> Hilaire
>

Thanks,

-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
https://independent.academia.edu/JuanVuletich
https://www.researchgate.net/profile/Juan-Vuletich
https://patents.justia.com/inventor/juan-manuel-vuletich
https://twitter.com/JuanVuletich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20220709/e94cb53f/attachment.htm>


More information about the Cuis-dev mailing list