Created
December 23, 2021 22:17
-
-
Save scymtym/c4b842f04fe37ef52745d3ed3ea97e50 to your computer and use it in GitHub Desktop.
Traits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cl:in-package #:language-extension.protocol.dispatch) | |
;;; | |
(defgeneric test (x)) | |
(p:defprotocol (role) specializer-test () | |
(:initarg :foo role) | |
(:method test ((x role)))) | |
(defclass test-class-2 () ()) | |
(defmethod test ((x test-class-2)) | |
:working) | |
(defclass test-class (test-class-2) | |
((%x :initarg :foo))) | |
(defclass unrelated () ()) | |
(defgeneric test-2 (x y) | |
(:generic-function-class protocol-generic-function)) | |
(defmethod test-2 ((x (protocol-role role specializer-test)) (y fixnum)) | |
(test x)) | |
#+later (test-2 (make-instance 'test-class)) | |
(specializer-test-role-p 1) | |
(specializer-test-role-p (c2mop:class-prototype (c2mop:ensure-finalized (find-class 'test-class)))) | |
(specializer-test-role-p (c2mop:class-prototype (c2mop:ensure-finalized (find-class 'test-class-2)))) | |
(test-2 (make-instance 'unrelated)) | |
(typep 1 '(protocol-role role specializer-test)) | |
(typep (c2mop:class-prototype (find-class 'test-class)) '(protocol-role role specializer-test)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment