Paste number 25320: the cases

Paste number 25320: the cases
Pasted by: jsnell
When:2 years, 9 months ago
Share:Tweet this! | http://paste.lisp.org/+JJC
Channel:#lisp
Paste contents:
Raw Source | XML | Display As
(declaim (optimize safety))

(defclass a () ((slot1 :initform 0.0 :type float :accessor slot1-of)))
(defclass b (a) ((slot1 :initform 0.0 :type single-float)))

(defmethod inheritance-test ((a a))
  (setf (slot-value a 'slot1) 1d0))

(inheritance-test (make-instance 'a))

;; Should this cause a type-error?
(inheritance-test (make-instance 'b))

(defmethod inheritance-test2 ((a a))
  (setf (slot1-of a) 1d0))

(inheritance-test2 (make-instance 'a))

;; Should this cause a type-error?
(inheritance-test2 (make-instance 'b))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.