[armedbear-devel] defun return value is not conforming.

Erik Huelsmann ehuels at gmail.com
Sat Nov 20 09:38:36 UTC 2010


Hi Alessio, Pascal,

The definition of DEFUN changes when the compiler is loaded (because
it's redefined in precompiler.lisp).

In this case you're correct Alessio, that they return the same thing.
However, the form should have been (PROG1 ...) instead of (PROGN ...),
because if there's documentation, the docstring will be returned, I
think. (it'll contain an additional (SETF (fdocumentation ...) ...))


My guess is that Pascal is running into issues with functions with
documentation at the start of the body.


Is that it?

Bye,


Erik.

On Sat, Nov 20, 2010 at 10:32 AM, Alessio Stalla
<alessiostalla at gmail.com> wrote:
> On Sat, Nov 20, 2010 at 7:26 AM, Pascal J. Bourguignon
> <pjb at informatimago.com> wrote:
>>
>> CLHS says:
>>
>>    Macro DEFUN
>>
>>    Syntax:
>>
>>    defun function-name lambda-list [[declaration* | documentation]] form*
>>
>>    => function-name
>>
>>    Arguments and Values:
>>
>>    function-name---a function name.
>>
>> and the glossary:
>>
>>    function name n. 1. (in an environment) A symbol or a list (setf
>>    symbol) that is the name of a function in that environment. 2. A
>>    symbol or a list (setf symbol).
>>
>>
>> Therefore (defun f () ...) should return the symbol F, not the function F.
>>
>> Unfortunately, after having loaded quicklisp, it looks like abcl switches
>> to another definition, which returns a function instead of a name:
>>
>> (macroexpand '(defun (x) (1+ x)))
>>
>> Before:  (SYSTEM:%DEFUN (QUOTE F) (LAMBDA (X) (BLOCK F (1+ X))))
>> (correct)
>>
>> After:   (PROGN (SYSTEM:%DEFUN (QUOTE F) (SYSTEM:NAMED-LAMBDA F (X) (BLOCK F (1+ X)))))
>> WRONG.
>
> I don't know what's causing the definition of DEFUN to change; but
> anyway both of your code snippets correctly return the symbol F. Are
> you sure that's the exact macroexpansion you get? (btw, the
> macroexpand form should be (macroexpand '(defun F (x) (1+ x))) -- f
> was missing).
> I'll try later to load quicklisp and reproduce the problem.
>
> Cheers,
> Alessio
>
> _______________________________________________
> armedbear-devel mailing list
> armedbear-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel
>




More information about the armedbear-devel mailing list