Pros and cons of different ways to declare types in Common Lisp?

lisp
common-lisp

#1

Suggested tags: lisp and common-lisp
Suggested category: no idea, it’s neither front-end nor back-end.

I have some stable code that should not (or rarely) change and I want to annotate it with types. However of the three ways to do it that I have found I do not see the pros and cons. My main purpose is safety and not optimization.

See this example and the three, commented out, ways to add type checks:

;(declaim (ftype (function (order integer) order) update-id)) ; [1]

(defmethod update-id ((o order) id)
  ;(declare (integer id))                                     ; [2]
  ;(check-type id integer)                                    ; [3]
  …

I would be interested in your preferences and reasons for them.

Oh! I’m using defmethod here for which [1] does not seem to work. It’s actually a second question but I would also be interested to know if it’s possible to make this work.