[pro] best practices on type safety of/for generic functions

John Morrison john.nmi.morrison at gmail.com
Tue Mar 26 15:20:50 UTC 2013


Hi All;

This is probably a dumb question, but here goes.

John Alan McDonald (Hi, John, if you're on this list!) has graciously
consented to let me try to revive some almost 20 year old CL software (
Arizona <http://home.comcast.net/~johnamcdonald/jamcdonald0/az93.pdf>).
SBCL doesn't seem to like type-related declarations in defgeneric forms
(per the spec<http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/mac_defgeneric.html#defgeneric>).
And there are a lot of defgenerics of the form:

(declaim (declaration :returns)) ;; OK, only once, but then used
repeatedly...

(defgeneric interactor-role-cursor (interactor role)
  (declare (type Interactor interactor)
       (type (or Interactor-Role Null) role)
       (:returns (type xlib:Cursor)))
  (:documentation
   "Returns the cursor to be used when this Role is current."))

(defmethod interactor-role-cursor ((interactor Interactor)
                   (role Interactor-Role))
  "The default cursor"
  (xlt:window-cursor (interactor-window interactor) :target))

I did certainly benefit from some of the runtime errors generated as a
result of the type declarations of some of the defmethods and defuns in my
efforts to update the clx parts of the software.

What is best practice, then, as regards trying to provide useful
type-related information associated with generic functions?  Or have I been
so brain-damaged by C++/Java/etc that I am thinking about the problem-space
entirely the wrong way, and thus my solution-space question is entirely
meaningless?

Thanks,

-jm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/pro/attachments/20130326/1fb548be/attachment.html>


More information about the pro mailing list