<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
On 5/15/2022 3:20 AM, Hilaire Fernandes via Cuis-dev wrote:
<blockquote cite="mid:e2da47d0-d7b7-6fde-5561-47cd9b007620@drgeo.eu"
type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<p> I changed the subject .</p>
<div>Le 14/05/2022 à 17:49, Juan Vuletich a écrit :<br>
</div>
<blockquote type="cite" cite="mid:627FCFA0.3090108@zoho.com"><br>
I think that #initialize should discard everything and start
anew.<br>
</blockquote>
<p>I was lazy to tackle the problem now as it will make the class
more complex.<br>
</p>
<blockquote type="cite" cite="mid:627FCFA0.3090108@zoho.com">
Please review the attach. It creates a new dictionary, populates
it, and only then installs it as the new ThePreferences. This is
a pattern that has been used in Squeak/Cuis many times.<br>
</blockquote>
<p>I don't really like much, it makes the class very verbose and
harder to understand, added redirections, but I don't have clear
workaround now. Analyzing now...<br>
</p>
</blockquote>
<br>
Yes. I agree. The attach includes your original proposal, with the
tweaks to #all and #select:.<br>
<br>
If we find the need to do better, we can think more about it.<br>
<br>
<blockquote cite="mid:e2da47d0-d7b7-6fde-5561-47cd9b007620@drgeo.eu"
type="cite">
<p> I am wondering: could it be possible to put Cuis in hold while
initializing, it will avoid race condition, and kept the class
simple, hum not really fancy, no idea of the implication of a
such approach.<br>
</p>
</blockquote>
<br>
I think that is risky. And harder to fix when it becomes a problem.<br>
<br>
<blockquote cite="mid:e2da47d0-d7b7-6fde-5561-47cd9b007620@drgeo.eu"
type="cite">
<p> Another idea is to use two class variables
PreferenceReadAccess and PreferenceWriteAccess . In normal
operation the two reference the same Dictionary. During
initialization, they are decoupled and PreferenceWriteAccess is
set to a new empty dictionary. #at: and #at:put: will be
rewritten accordingly to use these variables.</p>
</blockquote>
<br>
This could work wrt query accesses from same process, but would
require a critical section to not affect other processes. Not crazy
about it.<br>
<br>
<blockquote cite="mid:e2da47d0-d7b7-6fde-5561-47cd9b007620@drgeo.eu"
type="cite">
<p>It will keep the class simpler. I think I like this approach.<br>
</p>
<p>What do you think? If you agree I can make write the code.<br>
</p>
</blockquote>
<br>
I think the cleaner solution would be to again separate Preference
from Preferences, and just create a new instance of Preferences. I
know, that's the kind of complexity you wanted to get rid of in the
first place.<br>
<br>
I think the best now is to follow your original suggestion, as in
the attach. And if we see a real problem with this, we'll see.<br>
<br>
<blockquote cite="mid:e2da47d0-d7b7-6fde-5561-47cd9b007620@drgeo.eu"
type="cite">
<p> </p>
<p>Other observations:<br>
</p>
<p>The class method #name:description:category:type:value: is
needed, with it the user describes completely a new preference.
It is needed by external packages introducing their own
preferences. For example in the Locale package I have been
porting a few weeks ago there is:</p>
<p> Locale class>>initialize<br>
Smalltalk addToStartUpList: Locale.<br>
PreferenceNG <br>
name: #useLocale<br>
description: 'Use the system locale to set the system
language, etc., at startup. For time-zone handling, see
automaticTimezone.'<br>
category: #system<br>
type: Boolean<br>
value: false <br>
</p>
<p>The instance creation method #name:category:value is a
shorter/lazy one, where the system can deduce the type and no
description is provided. If one instance creation should be
removed it could be this one.<br>
</p>
<p><br>
</p>
<blockquote type="cite" cite="mid:627FCFA0.3090108@zoho.com"> <br>
BTW, I removed #select:, and renamed #all to #allPreferences. I
think this makes the stuff easier to find with </blockquote>
<p> #select: is needed for a preference browser. Applications
introducing a new category of preferences (think #drgeo category
for example) may want to use this selector too. I think it
should be reintroduced (with a better name?) it will avoid to
get it reintroduced in several application package.</p>
<p>Good point on #all!</p>
<p>Thanks<br>
</p>
<p>Hilaire<br>
</p>
<pre>--
GNU Dr. Geo
<a moz-do-not-send="true" href="http://drgeo.eu">http://drgeo.eu</a>
<a moz-do-not-send="true" href="http://blog.drgeo.eu">http://blog.drgeo.eu</a></pre>
</blockquote>
<br>
Maybe the attach is ok for you, and we're done. Please tell.<br>
<br>
Thanks,<br>
<pre class="moz-signature" cols="72">--
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a class="moz-txt-link-freetext" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a class="moz-txt-link-freetext" href="https://github.com/jvuletich">https://github.com/jvuletich</a>
<a class="moz-txt-link-freetext" href="https://www.linkedin.com/in/juan-vuletich-75611b3">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
<a class="moz-txt-link-freetext" href="https://independent.academia.edu/JuanVuletich">https://independent.academia.edu/JuanVuletich</a>
<a class="moz-txt-link-freetext" href="https://www.researchgate.net/profile/Juan-Vuletich">https://www.researchgate.net/profile/Juan-Vuletich</a>
<a class="moz-txt-link-freetext" href="https://patents.justia.com/inventor/juan-manuel-vuletich">https://patents.justia.com/inventor/juan-manuel-vuletich</a>
<a class="moz-txt-link-freetext" href="https://twitter.com/JuanVuletich">https://twitter.com/JuanVuletich</a></pre>
</body>
</html>