ccampbel@bambam.dsd.es.com (Colin Campbell) (02/15/91)
I want to write methods with order-insensitive arguments. Example:
geometric intersection of points, lines, planes, etc. I want to be
able to call
(geometric-intersection object-1 object-2)
where the args may be of type LINE and PLANE or PLANE and LINE, for instance.
What I do now is this:
(defgeneric geometric-intersection ((object-1 t) (object-2) &optional recursive-p)
(if recursive-p
(error "Can't intersect ~a and ~a" object-2 object-1)
(geometric-intersection object-2 object-1 t)))
i.e. if I find a method, I use it, otherwise I reverse the order of
the arguments and try again.
Does anybody have a better way to do this?
--
Colin Campbell
Evans & Sutherland
Salt Lake City, UT 84108
(801) 582-5847
ccampbel@dsd.es.com