analog of fundef for Maxima functions defined in lisp file
Subject: analog of fundef for Maxima functions defined in lisp file
From: Edwin Woollett
Date: Wed, 22 Jun 2011 11:42:09 -0700
On June ,2011, Steve Haflich wrote:
smh> There is a _standard_ interface for obtaining the soure for a
function
smh> See cl:function-lambda-epression. However, there are no requirements
on
smh> this function. The ANS allows this function always to return nil,
and
smh> indeed, a lambda function defined in a non-empty lexical evironment
smh> cannot be represented portably by its plain source sexpr.
smh>
smh> cl-user(10): (defun foo (x) (1+ x))
smh> foo
smh> cl-user(11): (function-lambda-expression #'foo)
smh> (lambda (x) (block foo (1+ x)))
smh> nil
Thanks for clarifying Allegro use, which works for me:
---------------------
CG-USER(1): (defun foo (x) (1+ x))
FOO
CG-USER(2): (foo 2)
3
CG-USER(3): (function-lambda-expression #'foo)
(LAMBDA (X) (BLOCK FOO (1+ X)))
NIL
FOO
--------------------------------
but CGL (via Maxima) fails:
MAXIMA> (defun foo (x) (1+ x))
FOO
MAXIMA> (foo 2)
3
MAXIMA> (function-lambda-expression #'foo)
Maxima encountered a Lisp error:
Error in EVAL [or a callee]: The function FUNCTION-LAMBDA-EXPRESSION is
undefined.
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
--------------------
Ted Woollett