<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi all,</p>
<p><br>
</p>
<p>please consider the following snippet and its output:</p>
<p><br>
</p>
<p></p>
<pre class="c-mrkdwn__pre" data-stringify-type="pre" style="box-sizing: inherit; margin-top: 4px; margin-bottom: 4px; padding: 8px; --saf-0:rgba(var(--sk_foreground_low,29,28,29),0.13); font-size: 12px; line-height: 1.50001; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4; border: 1px solid var(--saf-0); border-radius: 4px; background: rgba(var(--sk_foreground_min,29,28,29),0.04); counter-reset: list-0 0 list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; color: rgb(29, 28, 29); font-family: Monaco, Menlo, Consolas, "Courier New", monospace !important;">o := Object new.<br style="box-sizing: inherit;">o addDependent: 42.<br style="box-sizing: inherit;">o copy dependents. "#()"</pre>
<br>
<p></p>
<p>In my opinion, this behavior is misleading for two reasons:</p>
<p><span style="font-size: 12pt;">1.</span><span style="font-size: 12pt;"> #copy is documented as to "<span>answer another instance just like the receiver." From an abstract view of the object, this should include the object's dependents, too. Afaik, DependentsFields
 is only an implementation detail, but in common sense, the dependents are just another part of the object.</span></span></p>
<p><span style="font-size: 12pt;"><span>2. If you run exactly the same snippet with a Model instead of an Object (which implements dependencies in a different way under the hood), the copied object will contain the original dependencies, still. I think we should
 unify this undocumented and unintuitive discrepancy. The Model documentation states it features "<span>fast dependents maintenance" so the behavior should be kept, just optimized.</span></span></span></p>
<p><span style="font-size: 12pt;"><span><br>
</span></span></p>
<p><span style="font-size: 12pt;"><span>How do you think about this?</span></span></p>
<p><span style="font-size: 12pt;"><span>Can we change the Object behavior or could this introduce any unpredictable consequences?</span></span></p>
<p><span style="font-size: 12pt;">And how could we fix it?</span><br>
</p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">And what about #shallowCopy? Unfortunately, it is called directly by more than a hundred senders in the Trunk image. Because DependentsFields is an implementation detail, </span><span style="font-size: 12pt;">I wonder whether #shallowCopy
 should copy the dependents as well. Should we move the actual primitive </span><span style="font-size: 12pt;">method</span><span style="font-size: 12pt;"> to something like #primShallowCopy and in #shallowCopy, </span><span style="font-size: 12pt;">update
</span><span style="font-size: 12pt;">DependentsFields after calling the primitive? Or do we rather consider #shallowCopy as a low-level method (similar to #veryDeepCopyWith: as apposed to #veryDeepCopy) and call it a code smell to call #shallowCopy from a
 far-away place?</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">And LBNL: What should the following snippet output in your opinion?</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;"></span></p>
<pre class="c-mrkdwn__pre" data-stringify-type="pre" style="box-sizing: inherit; margin-top: 4px; margin-bottom: 4px; padding: 8px; --saf-0:rgba(var(--sk_foreground_low,29,28,29),0.13); font-size: 12px; line-height: 1.50001; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4; border: 1px solid var(--saf-0); border-radius: 4px; background: rgba(var(--sk_foreground_min,29,28,29),0.04); counter-reset: list-0 0 list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; color: rgb(29, 28, 29); font-family: Monaco, Menlo, Consolas, "Courier New", monospace !important;">o1 := Object new.<br style="box-sizing: inherit;">o1 addDependent: 42.<br style="box-sizing: inherit;">o2 := o1 shallowCopy.
o1 addDependent: 43.
o2 dependents asArray.</pre>
<p></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">Should it answer: a) #(), b) #(42), or c) #(42 43)? :D</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">I am looking forward to your opinions! :-)</span></p>
<p><span style="font-size: 12pt;"><br>
</span></p>
<p><span style="font-size: 12pt;">Best,</span></p>
<p><span style="font-size: 12pt;">Christoph</span></p>
<div id="Signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols;">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
</body>
</html>