[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EIEIO default constructor function
From: |
Mario Lang |
Subject: |
Re: EIEIO default constructor function |
Date: |
Sun, 04 Apr 2021 10:39:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> You might also consider using `cl-defstruct`, which
>>> doesn't suffer from such problems and is lighter weight.
>> I was actually trying that at first, but it turned out I need
>> inheritance based dynamic dispatch.
>
> I don't understand: cl-defmethod does inheritance-based dynamic
> dispatch for defstructs just as it does for defclasses.
Maybe I was using sloppy terminology, but as far as I can see, `cl-defstruct'
can not have a parent relationship, so what I call inheritance-based
dispatch isn't really possible with cl-defstruct?
(defclass foo () ())
(cl-defmethod val ((foo foo)) 0)
(defclass bar (foo) ())
(cl-defmethod val ((bar bar)) 1)
--
CYa,
⡍⠁⠗⠊⠕