In Common Lisp, is it portable to use make-instance
instead of make-condition
to make condition objects?
For example:
(define-condition foo (condition)
())
(make-condition 'foo)
(make-instance 'foo)
Does this have something to do with how conditions are placed in the CLOS class hierarchy? (subtypep 'condition 'standard-class)
returns false in SBCL and CLISP. However, make-instance
can make conditions in both implementations. Is this guaranteed by the standard?
No, it is explicitly not portable to do that. From the specification:
Conforming code must observe the following restrictions related to conditions:
define-condition
, notdefclass
, must be used to define new condition types.make-condition
, notmake-instance
, must be used to create condition objects explicitly.- The
:report
option ofdefine-condition
, notdefmethod
forprint-object
, must be used to define a condition reporter.slot-value
,slot-boundp
,slot-makunbound
, andwith-slots
must not be used on condition objects. Instead, the appropriate accessor functions (defined bydefine-condition
) should be used