Re: MAKE-INSTANCE and STRUCTURE-CLASS
David McClain <dbm-h9Lvq2qNYxl8mnqqp10EyDJtdDapTP/[email protected]> Sun, 12 Jul 2026 04:54:54 -0700
| Newsgroups | gmane.lisp.cl-pro,gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_C2CAC33A-6B8D-4C29-9011-DA11A24AABED Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Well, I have to retract my claim=E2=80=A6 I get runtime errors when I = execute the make-instances=E2=80=A6 Not sure why the whole image managed = to compile and load without showing any errors. I was sure that there = were some trees being constructed. But apparently not. > On Jul 12, 2026, at 04:35, David McClain (as dbm at = refined-audiometrics dot com) <[email protected]> wrote: >=20 > I just accidentally ran into this very thing - calling MAKE-INSTANCE = on a STRUCT class. And it worked just fine for me. No LW errors and no = SBCL errors. >=20 > Here was my struct, which replaced a former class object: >=20 > (defstruct node > l v r > (h 1)) >=20 >=20 > =E2=80=A6 and here were some of the MAKE-INSTANCE calls: > ;; =E2=80=94------------------------------------------ >=20 > (defun singleton-node (x) > (make-instance 'node > :v x)) >=20 > (defun create (l v r &optional (hl (height l)) (hr (height r))) > (declare (fixnum hl hr)) > (make-instance 'node > :l l :v v :r r > :h (the fixnum (1+ (max hl hr))))) >=20 >=20 > (if (funcall *replace-p* v x) > (make-instance 'node > :l l :v x :r r :h h) >=20 > ((minusp c) > (and (subset (make-instance 'node > :l l1 :v v1) > l2) > (subset r1 s2))) >=20 > (t (and (subset (make-instance 'node > :v v1 :r r1) > r2) > (subset l1 s2))) >=20 >=20 > ;; =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94 >=20 > All of these MAKE-INSTANCE work just fine for me in both LW and SBCL. = So I don=E2=80=99t understand your original complaint about missing = methods? >=20 > - DM >=20 >=20 >> On Jul 5, 2026, at 05:23, Marco Antoniotti (as marco dot antoniotti = at unimib dot it) <[email protected]> wrote: >>=20 >> Hi >>=20 >> I am sure this has come up a godzillion times before, but how do you = write methods for MAKE-INSTANCE with structure classes? >>=20 >> Just writing a method on the class name then hits a MISSING-METHOD on = MAKE-INSTANCE and STRUCTURE-CLASS (at least on LW). >>=20 >> Thanks >>=20 >> MA >>=20 >=20 --Apple-Mail=_C2CAC33A-6B8D-4C29-9011-DA11A24AABED Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html aria-label=3D"message body"><head><meta http-equiv=3D"content-type" = content=3D"text/html; charset=3Dutf-8"></head><body = style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; = line-break: after-white-space;">Well, I have to retract my claim=E2=80=A6 = I get runtime errors when I execute the make-instances=E2=80=A6 Not sure = why the whole image managed to compile and load without showing any = errors. I was sure that there were some trees being constructed. But = apparently not.<div><br></div><div><br></div><div><br = id=3D"lineBreakAtBeginningOfMessage"><div><br><blockquote = type=3D"cite"><div>On Jul 12, 2026, at 04:35, David McClain (as dbm at = refined-audiometrics dot com) <[email protected]> = wrote:</div><br class=3D"Apple-interchange-newline"><div><meta = http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8"><div = style=3D"overflow-wrap: break-word; -webkit-nbsp-mode: space; = line-break: after-white-space;">I just accidentally ran into this very = thing - calling MAKE-INSTANCE on a STRUCT class. And it worked just fine = for me. No LW errors and no SBCL errors.<div><br></div><div>Here was my = struct, which replaced a former class = object:</div><div><br></div><div><div><font face=3D"Monaco">(defstruct = node</font></div><div><font face=3D"Monaco"> l v = r</font></div><div><font face=3D"Monaco"> (h = 1))</font></div><div><br></div><div><br></div><div>=E2=80=A6 and here = were some of the MAKE-INSTANCE calls:</div><div>;; = =E2=80=94------------------------------------------</div><div><br></div><d= iv><div>(defun singleton-node (x)</div><div> (make-instance = 'node</div><div> :v = x))</div><div><br></div><div><div>(defun create (l v r = &optional (hl (height l)) (hr (height r)))</div><div> (declare = (fixnum hl hr))</div><div> (make-instance 'node</div><div> = :l l :v v :r r</div><div> = :h (the fixnum (1+ (max hl = hr)))))</div></div><div><br></div><div><br></div><div><div> = (if = (funcall *replace-p* v x)</div><div> = (make-instance = 'node</div><div> = = :l l :v x :r r :h = h)</div></div><div><br></div><div><div> = ((minusp c)</div><div> = (and (subset (make-instance = 'node</div><div> = :l l1 = :v v1)</div><div> = = l2)</div><div> = (subset r1 s2)))</div><div><br></div><div> = (t (and (subset (make-instance = 'node</div><div> = :v = v1 :r r1)</div><div> = = r2)</div><div> = (subset l1 = s2)))</div></div><div><br></div><div><br></div><div>;; = =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2= =80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80= =94=E2=80=94=E2=80=94=E2=80=94</div><div><br></div><div>All of these = MAKE-INSTANCE work just fine for me in both LW and SBCL. So I don=E2=80=99= t understand your original complaint about missing = methods?</div><div><br></div><div>- = DM</div><div><br></div><div><br><blockquote type=3D"cite"><div>On Jul 5, = 2026, at 05:23, Marco Antoniotti (as marco dot antoniotti at unimib dot = it) <[email protected]> wrote:</div><br = class=3D"Apple-interchange-newline"><div><div = dir=3D"ltr"><div>Hi</div><div><br></div><div>I am sure this has come up = a godzillion times before, but how do you write methods for = MAKE-INSTANCE with structure classes?</div><div><br></div><div>Just = writing a method on the class name then hits a MISSING-METHOD on = MAKE-INSTANCE and STRUCTURE-CLASS (at least on = LW).</div><div><br></div><div>Thanks</div><div><br></div><div>MA</div><br>= </div> = </div></blockquote></div><br></div></div></div></div></blockquote></div><b= r></div></body></html>= --Apple-Mail=_C2CAC33A-6B8D-4C29-9011-DA11A24AABED--