🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #679

Re: method definition question

#679
From: ....What Is?....
Date: Thu, 27 Jun 1991 04:03
38 lines
2454 bytes
In article <LGM.91Jun18195405@cbnewsc.ATT.COM> lgm@cbnewsc.ATT.COM (lawrence.g.mayka) writes:
>In article <1991Jun17.210108.29347@Think.COM> barmar@think.com (Barry Margolin) writes:
>In article <ALANR.91Jun17130803@chopin.media-lab.media.mit.edu> alanr@chopin.media-lab.media.mit.edu (Alan Ruttenberg) writes:
>>(deftype C () '(or A B))
>>
>>(defmethod common ((instance C))
>> ...)
>>
>>This doesn't work. (can't find class C)
>>
>>My only two choices seem to be to either replicate the code, or to factor the
>>body of the definition of common into a defun which is called by both.
>
>If A and B have any ancestors in common you could define the method on a
>common ancestor, and then use (check-type instance 'C) to catch misuse.
>But that's also pretty inelegant.  

I'm having a similar problem.  I wrote an AVL tree in Lisp a few
months back using a 4-element list as my basic data structure (left,
data, height, right).  Now I'm trying to convert it to CLOS.  I
defined the methods with parameter specializers that make them take
my avl-tree class, but I need to be able to have "no avl-tree", which
I was implementing as "nil".  But of course none of the avl-tree
methods recognize the null stuff.  Is factoring the only way to
get my methods to recognize both avl-tree and null as valid instances
of avl-tree?  I tried (defclass avl-tree (null) blah blah blah) but
it didn't help.

If there is no really good solution to this, I'll be amazed, since
out of the OOP paradigms I've seen so far, CLOS has been the best.

Steve Boswell         | This opinion is distributed in the hopes that it
whatis@ucsd.edu       | will be useful, but WITHOUT ANY WARRANTY...
whatis@gnu.ai.mit.edu |
-- 
Steve Boswell         | This opinion is distributed in the hopes that it
whatis@ucsd.edu       | will be useful, but WITHOUT ANY WARRANTY...
whatis@gnu.ai.mit.edu |
Technical Details
Message-ID: <21012@sdcc6.ucsd.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!sdcc6!sdcc13!sboswell
References: <ALANR.91Jun17130803@chopin.media-lab.media.mit.edu> <1991Jun17.210108.29347@Think.COM> <LGM.91Jun18195405@cbnewsc.ATT.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!ucsd!sdcc6!sdcc13!sboswell
From: sboswell@sdcc13.ucsd.edu (....What Is?....)
Newsgroups: comp.lang.clos
Subject: Re: method definition question
Message-ID: <21012@sdcc6.ucsd.edu>
Date: 27 Jun 91 04:03:27 GMT
References: <ALANR.91Jun17130803@chopin.media-lab.media.mit.edu> <1991Jun17.210108.29347@Think.COM> <LGM.91Jun18195405@cbnewsc.ATT.COM>
Sender: news@sdcc6.ucsd.edu
Organization: UC San Diego -- 1991 "Wannabe Real College" finalist
Lines: 38