<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 4, 2016 at 1:58 PM, marcel.taeumel <span dir="ltr">&lt;<a href="mailto:Marcel.Taeumel@hpi.de" target="_blank">Marcel.Taeumel@hpi.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Eliot Miranda-2 wrote<br>
&gt; On Mon, Jul 4, 2016 at 1:59 PM, Tobias Pape &amp;lt;<br>
<br>
&gt; Das.Linux@<br>
<br>
&gt; &amp;gt; wrote:<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 04.07.2016, at 22:44, Eliot Miranda &amp;lt;<br>
<br>
&gt; eliot.miranda@<br>
<div><div class="h5"><br>
&gt; &amp;gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; &gt; Hi All, Hi Marcel,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;     when I see code like this, and there&#39;s a lot of it in Morphic,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; !Flaps class methodsFor: &#39;testing&#39; stamp: &#39;mt 5/17/2016 14:17&#39;!<br>
&gt;&gt; &gt; anyFlapsVisibleIn: aWorld<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         aWorld submorphsDo: [:m |<br>
&gt;&gt; &gt;                 (m isKindOf: FlapTab) ifTrue: [^ true]].<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         ^ false! !<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I think this is performance thrown on the floor (isKindOf: is awfully<br>
&gt;&gt; slow, especially in huge hierarchies like Morphic, and bad design,<br>
&gt;&gt; restricting one to a concrete class).  And I think that Morph provides a<br>
&gt;&gt; perfect place to put an extension that doesn&#39;t pollute Object.  So I<br>
&gt;&gt; would<br>
&gt;&gt; like to see<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; anyFlapsVisibleIn: aWorld<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;         aWorld submorphsDo:<br>
&gt;&gt; &gt;                [:m| m isFlapTab ifTrue: [^true]].<br>
&gt;&gt; &gt;         ^ false! !<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; with the emphasis on isFlapTab ;-)<br>
&gt;&gt;<br>
&gt;&gt; Well, class testing seems to be a Morphic pattern, given #findA: (alias<br>
&gt;&gt; #submorphOfClass:)<br>
&gt;&gt;<br>
&gt;<br>
&gt; I don&#39;t care.  It&#39;s *WRONG*.  isKindOf: is a _bug_.<br>
&gt;<br>
&gt;<br>
&gt;&gt;<br>
&gt;&gt; Best regards<br>
&gt;&gt;         -Tobias<br>
&gt;&gt; PS: Not advocating anything just reporting what I found<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; _,,,^..^,,,_<br>
&gt; best, Eliot<br>
<br>
</div></div>Hey Eliot,<br>
<br>
no, it&#39;s not a bug. ;-) </blockquote><div><br></div><div>Yes, isKindOf: *is* a bug, at least in the usage of determining supported messages.  Smalltalk has ad-hoc polymorphism that allows any class to implement and set of messages, without having to inherit from a superclasss that defines that set of messages.  isKindOf: breaks this property; it restricts the designer to using a concrete class, in violation of the language&#39;s flexibility.  isKindOf: is therefore most definitely a bug.  </div><div> </div><div>One might think there are valid uses when editing a class hierarchy programmatically.  But for this there are messages understood by classes, not instances, such as includesBehavior:, inheritsFrom: etc.  These are legitimate.  But isKindOf: is not.  It is a horrible hack.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Although, there is room for improvement. #isFlapTab<br>
sounds good. Note that this is not even a critical piece of code because is<br>
only called if you open a system window, for example.<br>
<br>
Try [Flaps anyFlapsVisibleIn: ActiveWorld] bench. It&#39;s fast enough. A<br>
microsecond here, having around 30 windows open. So, you will not notice a<br>
delay. Still, you&#39;re right. We should reduce the usage of #isKindOf:.<br>
<br>
Not polluting Object means still polluting Morph.<br>
<br>
(Yeah, maybe we should use slower computers to program.)<br>
<br>
Checks we should consider to add or use more often if it is already there:<br>
#isCornerGripMorph<br>
#isProportionalSplitterMorph<br>
#isCompiledMethod<br>
#isColor<br>
#isInfiniteForm<br>
<br>
... still, a quick look through the usage of #isKindOf: in Morphic code<br>
revealed no serious performance issues. We should refactor MenuMorph to not<br>
need #isKindOf: that often. This might also be true for other places.<br>
<br>
The pattern &quot;isClass&quot; is not always a good solution for many cases in the<br>
system.<br>
<br>
Best,<br>
Marcel<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://forum.world.st/isKindOf-in-Morphic-code-tp4904890p4904895.html" rel="noreferrer" target="_blank">http://forum.world.st/isKindOf-in-Morphic-code-tp4904890p4904895.html</a><br>
Sent from the Squeak - Dev mailing list archive at Nabble.com.<br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>