Skip to content

Instantly share code, notes, and snippets.

@marcoheisig
Last active June 20, 2020 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoheisig/44c6b5f0c9a560335b1f772b4b4087a6 to your computer and use it in GitHub Desktop.
Save marcoheisig/44c6b5f0c9a560335b1f772b4b4087a6 to your computer and use it in GitHub Desktop.
A possible safe implementation of typed cells for SICL.
(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