Re: compile vs coerce
I've run into this sort of thing before but there were lexical
bindings in my case; I believe the problem to be that without the
quote around the inner lambda, that lambda is evaluated to produce an
interpreted function, and because it is within a lexical context (the
outer lambda) it is considered a lexical closure albeit with zero
bindings.
Because of the differences in lexical environment implementation
between compiled and interpreted contexts, the compiler throws this
error. If that's the case, perhaps LW could be improved to recognise
when the lexical environment is empty and proceed without error.
On 26 November 2015 at 06:38, Christopher Riesbeck
<c-riesbeck@northwestern.edu> wrote:
>
>
> On 11/25/2015 12:43 PM, Pascal J. Bourguignon wrote:
>>
>> Christopher Riesbeck <c-riesbeck@northwestern.edu> writes:
>>
>>> In Lispworks,why does
>>>
>>> (funcall (lambda () (coerce (lambda () nil) 'function)))
>>>
>>> run but
>>>
>>> (funcall (lambda () (compile nil (lambda () nil))))
>>>
>>> causes Error: #<anonymous interpreted function 200C8D82> is a
>>> lexical closure.
>>
>> There should be no difference, and no error generated.
>>
>> Are you sure lispworks generates the error you're saying, when you
>> evaluate either of those forms?
>>
>> Try with (cl:lambda () cl:nil)
>
>
> Listener output, Lispworks 6 Personal Edition, nothing loaded. Adding
> package qualifiers everywhere:
>
>> CL-USER 5 > (cl:funcall (cl:lambda () (cl:compile cl:nil (cl:lambda ()
>> cl:nil))))
>>
>> Error: #<anonymous interpreted function 21AF2EB2> is a lexical closure.
>
>
>
>> The specification of compile is clear, the definition can be a lambda
>> expression or a function. In your case, it's a function (as returned by
>> (lambda () nil), and it doesn't matter whether it's a lexical closure,
>> an interpreted function or a compiled function. Compile should return
>> an equivalent compiled function.
>
> Being a function does seem matter here, because the following does NOT
> signal an error
>
>> CL-USER 7 > (funcall (lambda () (compile nil '(lambda () nil))))
>> #<Function 10 21CD5F22>
>> NIL
>> NIL
>
>
> --
> ................................................
> Christopher Riesbeck
> Associate Professor, Electrical Engineering and Computer Science
> McCormick School of Engineering
> Northwestern University
>
> 2145 Sheridan Rd., Evanston, IL 60208
>
> Home page: http://www.cs.northwestern.edu/~riesbeck/
> Calendar: http://www.cs.northwestern.edu/~riesbeck/calendar.html
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html