Last active
February 13, 2023 23:54
-
-
Save jakub-stastny/ed50811d1459f4376929c248137a00e3 to your computer and use it in GitHub Desktop.
This file contains 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
(defprotocol Version | |
"Version numbers of various levels connected by a dot: X.Y.Z" | |
(stringify [this] "Get string representation")) | |
(deftype QID | |
[a b c d] Version | |
(stringify [this] | |
(str (.a this) "." (.b this) "." (.c this) "." (.d this)))) | |
(defmethod print-method QID [object out] | |
(.write out (str (stringify object)))) | |
(println (stringify (QID. 4 0 0 1))) ; 4.0.0.1 calling explicitly | |
(println (str (QID. 4 0 0 1))) ; user.QID@5f38e560 <===== ? | |
(println (QID. 4 0 0 1)) ; 4.0.0.1 print-method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment