getting the function name of a compiled function
Does anyone know the (apparently undocumented, internal) way to get the name of a compiled function? I.e, something like (function-name (symbol-function 'car)) -> CAR (for any function). Thanks!
Does anyone know the (apparently undocumented, internal) way to get the name of a compiled function? I.e, something like (function-name (symbol-function 'car)) -> CAR (for any function). Thanks!
* Miller Bradford-ABM wrote: > Does anyone know the (apparently undocumented, internal) way to get the name of a compiled function? > I.e, something like > (function-name (symbol-function 'car)) -> CAR The third value of FUNCTION-LAMBDA-EXPRESSION is the `name' of a function, or NIL meaning (I think) either `has no name' or `I don't know the name'. In LWW: (function-lambda-expression #'car) -> NIL, NIL, CAR and (function-lambda-expression #'(lambda (x) x)) -> (LAMBDA (X) X), NIL, NIL (the other values are defined in the spec) --tim
Brad Miller <Bradford.W.Miller@motorola.com> writes: > Thanks, this does seem to be the ANSI defined way to do this. > Unfortunately, it does not appear to be a reliable way to find out > the name of a function: > > CL-USER 40 > (defun bar () t) > BAR > > CL-USER 41 > (compile 'bar) > BAR > NIL > NIL > > CL-USER 42 > (function-lambda-expression #'bar) > NIL > NIL > NIL > > CL-USER 43 > (describe #'bar) > > #<function 20671D12> is a LOW:COMPILED-FUNCTION-OBJECT > CODE #<code BAR (26) 20671D12> > CONSTANTS (T #<function 20045DC2>) > > CL-USER 44 > > > So LW knows that the name of the code is BAR but it isn't letting me > get to this information via function-lambda-expression... I suspect this is due to some optimization settings that you may have in your init file. This is what I get with a freshly started Lisp image (LWL 4.2 Personal Edition): CL-USER 1 > (defun bar () t) BAR CL-USER 2 > (compile 'bar) BAR NIL NIL CL-USER 3 > (function-lambda-expression #'bar) NIL NIL BAR CL-USER 4 > (proclaim '(optimize (debug 0))) NIL CL-USER 5 > (defun foo () t) FOO CL-USER 6 > (compile 'foo) FOO NIL NIL CL-USER 7 > (function-lambda-expression #'foo) NIL NIL NIL CL-USER 8 > Edi.
* Brad Miller wrote: > Thanks, this does seem to be the ANSI defined way to do this. > Unfortunately, it does not appear to be a reliable way to find > out the name of a function: > CL-USER 40 > (defun bar () t) > BAR > CL-USER 41 > (compile 'bar) > BAR > NIL > NIL > CL-USER 42 > (function-lambda-expression #'bar) > NIL > NIL > NIL Which LW are you using? This works for me in both LWL 4.2.6 and LWW 4.2.6. Are you using compilation options which cause it to drop a lot of information? --tim