Advertisement
Guest User

sbcl optimization bug

a guest
Apr 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.88 KB | None | 0 0
  1. (defmacro mfoo () '(lambda (z) (1+ z)))
  2.  
  3. ;; f-macro, f-symb-macro, f-macrolet have a function call to a compiled lambda in disassembly
  4.  
  5. (defun f-macro (x)
  6.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  7.   (funcall (mfoo) x))
  8.  
  9. (defun f-symb-macro (x)
  10.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  11.   (symbol-macrolet ((mfoo-new (lambda (z) (1+ z))))
  12.     (funcall mfoo-new x)))
  13.  
  14. (defun f-macrolet (x)
  15.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  16.   (macrolet ((mfoo-new () '(lambda (z) (1+ z))))
  17.     (funcall (mfoo-new) x)))
  18.  
  19. ;; f-bare and f-flet-macro have the same disassembly, and both call
  20. ;; #'1+ directly
  21.  
  22. (defun f-bare (x)
  23.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  24.   (funcall (lambda (z) (1+ z)) x))
  25.  
  26. (defun f-flet-macro (x)
  27.   (declare (optimize (speed 3) (safety 0) (debug 0)))
  28.   (flet ((f (x) (funcall (mfoo) x)))
  29.     (funcall #'f x)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement