this post was submitted on 20 Nov 2023
1 points (100.0% liked)

Lisp

53 readers
3 users here now

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] monkoose@alien.top 1 points 11 months ago (1 children)

Second, redefining the F function will update its association (or binding) to the F symbol, but the previous function will still be available if it has been referenced somewhere before the update. For example:

(setf (symbol-function 'foo) #'1+)
(let ((old-foo #'foo))
  (setf (symbol-function 'foo) #'1-)
  (funcall old-foo 42))

It still return 41 on sbcl

[–] SlowValue@alien.top 1 points 11 months ago
(lisp-implementation-type)
;; ⇒ "SBCL"
(lisp-implementation-version)
;; ⇒ "2.3.10"
(setf (symbol-function 'foo) #'1+)
;; ⇒ #
(let ((old-foo #'foo))
  (setf (symbol-function 'foo) #'1-)
  (funcall old-foo 42))
;; ⇒ 43 (6 bits, #x2B, #o53, #b101011)