Panicz Maciej Godek<p>Having programmed in Kawa for over a year now, and having programmed in Guile for some time before, I have some thoughts regarding <a href="https://functional.cafe/tags/Java" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Java</span></a> vs Common <a href="https://functional.cafe/tags/Lisp" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>Lisp</span></a>.</p><p>I haven't used Java all that much, and Common Lisp even less, but I think that Guile's <a href="https://functional.cafe/tags/GOOPS" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>GOOPS</span></a> system is similar to <a href="https://functional.cafe/tags/CLOS" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>CLOS</span></a> - and likewise, the OO system in Kawa literally is that of Java.</p><p>I remember the time when I was making set of GUI widgets for my humanoid robot pose editor. I was using GOOPS for that, and I feel that it was a total mess. Well, it did work, but I don't want to go back to that code.</p><p>I was using GOOPS in many other ways, for example - to overload various math operations for matrices and quaternions. The code I wrote back then can still be admired, say, here:</p><p><a href="https://github.com/panicz/slayer/blob/master/guile-modules/extra/math.scm" rel="nofollow noopener noreferrer" translate="no" target="_blank"><span class="invisible">https://</span><span class="ellipsis">github.com/panicz/slayer/blob/</span><span class="invisible">master/guile-modules/extra/math.scm</span></a></p><p>I think it was today that I got enlightened on what I really didn't like about the GOOPS/CLOS approach with generic and multimethods. It may seem like extremely flexible system, but I think that multimethods combined with subclasses are a terrible idea in practice.</p><p>Suppose that we have a base class <A></p><p>(define-class <A> ())<br>(define a (make <A>))</p><p>and its two subclasses:</p><p>(define-class <B> (<A>))<br>(define b (make <B>))</p><p>(define-class <C> (<A>))<br>(define c (make <C>))</p><p>Now, suppose that I also have a generic method:</p><p>(define-method (m (x <A>) (y <A>)) 'aa)</p><p>and its two specializations</p><p>(define-method (m (x <B>) (y <A>)) 'ba)</p><p>(define-method (m (x <A>) (y <C>)) 'ac)</p><p>Now, what is going to happen when I invoke</p><p>(m b c)</p><p>?</p><p>I checked it with Guile, and it chose the 'ba implementation. I don't know if that's because it was defined earlier, or because the method specialization is defined to be resolved from left to right - and frankly, I don't care.</p><p>Imagine that one programmer wrote the 'ac implementation and had some working code. Now, if another programmer comes and defines the 'ba variant, they would break the existing code. And this is the fundamental problem.</p>