
(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)))