Guest User

Untitled

a guest
Jun 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. (annot:defannotation fntype (args result form)
  2. (:arity 3)
  3. (let* ((last-form (cl-annot.util:progn-form-last form))
  4. (symbol (cl-annot.util:definition-form-symbol last-form)))
  5. `(progn (declaim (ftype (function ,args ,result) ,symbol))
  6. ,form)))
  7.  
  8. ;; Usage:
  9. ;; (ql:quickload :cl-syntax)
  10. ;; (syntax:use-syntax :annot)
  11. ;;
  12. ;; @fntype (fixnum) fixnum
  13. ;; (defun fib (n)
  14. ;; (if (<= n 1)
  15. ;; 1
  16. ;; (+ (fib (1- n)) (fib (- n 2)))))
  17. ;;
  18. ;; ;; OK
  19. ;; (defun fib10 () (fib 10))
  20. ;;
  21. ;; ;; Compilation Warning
  22. ;; (defun fibx () (fib 'x))
  23. ;;
  24. ;; ; caught WARNING:
  25. ;; ; Constant X conflicts with its asserted type FIXNUM.
  26. ;; ; See also:
  27. ;; ; The SBCL Manual, Node "Handling of Types"
  28. ;; ;
  29. ;; ; compilation unit finished
  30. ;; ; caught 1 WARNING condition
Add Comment
Please, Sign In to add comment