many Lisp systems record the source location and/or the source itself (especially a source level interpreter needs that)
Doesn't FUNCTION-LAMBDA-EXPRESSION apply here?
As for CCL, it seems to work for me just fine as long as you set CCL:*SAVE-DEFINITIONS* to T:
Clozure Common Lisp Version 1.12.1 (v1.12.1) LinuxX8664
For more information about CCL, please see http://ccl.clozure.com.
CCL is free software. It is distributed under the terms of the Apache
Licence, Version 2.0.
? (defun foobar (a b c) (* a (+ b c)))
FOOBAR
? (function-lambda-expression #'foobar)
NIL
NIL
FOOBAR
? (setf ccl:*save-definitions* t)
T
? (defun foobar (a b c) (* a (+ b c)))
FOOBAR
? (function-lambda-expression #'foobar)
(LAMBDA (A B C) (DECLARE (CCL::GLOBAL-FUNCTION-NAME FOOBAR)) (BLOCK FOOBAR (* A (+ B C))))
NIL
FOOBARhttp://www.lispworks.com/documentation/lw80/lw/lw-dspecs-ug....
Common Lisp has standard function FUNCTION-LAMBDA-EXPRESSION:
* (defun foo (a)
(my-if (> a 10) 'big 'small))
FOO
* (function-lambda-expression #'foo)
(LAMBDA (A) (BLOCK FOO (MY-IF (> A 10) 'BIG 'SMALL)))
T
FOO