• monkoose@alien.topB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    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.topB
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year 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)