Re: MAKE-INSTANCE and STRUCTURE-CLASS
David McClain <dbm-h9Lvq2qNYxl8mnqqp10EyDJtdDapTP/[email protected]> Sun, 12 Jul 2026 04:35:36 -0700
| Newsgroups | gmane.lisp.cl-pro,gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_17EA6EAD-1F7F-4E82-A66D-99D0AC73A999
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=utf-8
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.
Here was my struct, which replaced a former class object:
(defstruct node
l v r
(h 1))
=E2=80=A6 and here were some of the MAKE-INSTANCE calls:
;; =E2=80=94------------------------------------------
(defun singleton-node (x)
(make-instance 'node
:v x))
(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)))))
(if (funcall *replace-p* v x)
(make-instance 'node
:l l :v x :r r :h h)
((minusp c)
(and (subset (make-instance 'node
:l l1 :v v1)
l2)
(subset r1 s2)))
(t (and (subset (make-instance 'node
:v v1 :r r1)
r2)
(subset l1 s2)))
;; =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
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?
- DM
> 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
--Apple-Mail=_17EA6EAD-1F7F-4E82-A66D-99D0AC73A999
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;">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></body></html>=
--Apple-Mail=_17EA6EAD-1F7F-4E82-A66D-99D0AC73A999--