Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (annot:defannotation fntype (args result form)
- (:arity 3)
- (let* ((last-form (cl-annot.util:progn-form-last form))
- (symbol (cl-annot.util:definition-form-symbol last-form)))
- `(progn (declaim (ftype (function ,args ,result) ,symbol))
- ,form)))
- ;; Usage:
- ;; (ql:quickload :cl-syntax)
- ;; (syntax:use-syntax :annot)
- ;;
- ;; @fntype (fixnum) fixnum
- ;; (defun fib (n)
- ;; (if (<= n 1)
- ;; 1
- ;; (+ (fib (1- n)) (fib (- n 2)))))
- ;;
- ;; ;; OK
- ;; (defun fib10 () (fib 10))
- ;;
- ;; ;; Compilation Warning
- ;; (defun fibx () (fib 'x))
- ;;
- ;; ; caught WARNING:
- ;; ; Constant X conflicts with its asserted type FIXNUM.
- ;; ; See also:
- ;; ; The SBCL Manual, Node "Handling of Types"
- ;; ;
- ;; ; compilation unit finished
- ;; ; caught 1 WARNING condition
Add Comment
Please, Sign In to add comment