Bill_Clementson@peoplesoft.com writes:
Unfortunately, it does not work in 6.x - it just positions to the top of the file that the method is in.
May I ask what the attached snippet returns for you? I tried it with Franz' telnet prompt at prompt.franz.com (a 6.2) and it seems ok. ACL5 returns:
((BAR #((:FILE "/tmp/foo.lisp") (:POSITION 22))) ((METHOD FOO ((EQL :A))) #((:FILE "/tmp/foo.lisp") (:POSITION 38))) ((METHOD FOO ((EQL :B))) #((:FILE "/tmp/foo.lisp") (:POSITION 71))) (FOO #((:FILE "/tmp/foo.lisp") (:FUNCTION-NAME "FOO"))))
(progn
(defun find-fspec-location (fspec type) (let* ((fspec (if (consp fspec) (excl::to-internal-fspec fspec) fspec)) (info (car (excl::fspec-fspec-info fspec))) (file (excl::fspec-info-pathname info))) (etypecase file (pathname (let ((start (scm:find-definition-in-file fspec type file))) (vector (list :file (namestring (truename file))) (if start (list :position (1+ start)) (list :function-name (string (third info))))))) ((member :top-level) (list :error (format nil "Defined at toplevel: ~A" fspec))) (null (list :error (format nil "Unkown source location for ~A" fspec))))))
(defun fspec-definition-locations (fspec) (let ((defs (excl::find-multiple-definitions fspec))) (loop for (fspec type) in defs collect (list fspec (find-fspec-location fspec type)))))
(defun find-definitions (symbol) (fspec-definition-locations symbol))
(defparameter prog (format nil "~{~s~%~}" '((defgeneric foo (x)) (defun bar (x)) (defmethod foo ((x (eql :a))) x) (defmethod foo ((x (eql :b))) (cons x xx))))) (with-open-file (s "/tmp/foo.lisp" :if-does-not-exist :create :direction :output :if-exists :overwrite) (write-string prog s))
(compile-file "/tmp/foo.lisp" :load-after-compile t)
(append (find-definitions 'bar) (find-definitions 'foo)))