Last active
June 20, 2020 06:34
-
-
Save marcoheisig/44c6b5f0c9a560335b1f772b4b4087a6 to your computer and use it in GitHub Desktop.
A possible safe implementation of typed cells for SICL.
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
(defun make-function-cell (value) | |
(check-type value function) | |
(values | |
(lambda () value) | |
(lambda (new-value) | |
(check-type new-value function) | |
(setf value new-value)))) | |
;; In order to make typed cells as fast as cons cells, | |
;; the compiler has to be able to inline the first value returned by | |
;; MAKE-FUNCTION-CELL even though it is a closure. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment