[Openmcl-devel] function-lambda-list

R. Matthew Emerson rme at clozure.com
Mon Jul 9 20:15:33 PDT 2012


On Jul 9, 2012, at 9:08 PM, Burton Samograd wrote:

> On 12-07-09 07:02 PM, Stas Boukarev wrote:
>> (ccl:decode-string-from-octets (ccl::source-note-source (ccl:function-source-note #'add)))
> 
> Oddly, it works when I run CCL from the command line, but not when I run from within SLIME:
> 
> CL-USER> (defun add (x) (1+ x))
> ADD
> CL-USER> (ccl:decode-string-from-octets (ccl::source-note-source (ccl:function-source-note #'add)))
> ; Evaluation aborted on #<TYPE-ERROR #x30200278979D>.
> CL-USER> (ccl:decode-string-from-octets (ccl::source-note-source (ccl:function-source-note #'add)))
> ; Evaluation aborted on #<TYPE-ERROR #x30200284D12D>.
> CL-USER> (ccl:function-source-note #'add)
> NIL
> CL-USER> (ccl:function-source-note 'add)
> NIL
> CL-USER>

SLIME's repl probably doesn't read toplevel forms in the same
way that CCL does from the command line.

CCL's read-loop can save source information for interactively
entered forms.  This can be handy for disassembly, because
the source information will be used to annotate the
disassembly output.

I think it still works to set ccl:*save-definitions* to t.
Then, function-lambda-expression will return something.
This was to support an interpreter (and stepper), but the
interpreter is long gone.

? (setq *save-definitions* t)
T
? (defun junk (x) (1+ x))
JUNK
? (function-lambda-expression #'junk)
(LAMBDA (X) (DECLARE (GLOBAL-FUNCTION-NAME JUNK)) (BLOCK JUNK (1+ X)))
NIL
JUNK
? 

Generally, though, if you want to save the source code for a
function, it's best to save it in a file.




More information about the Openmcl-devel mailing list