gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Re: error in compile


From: Peter Wood
Subject: Re: [Gcl-devel] Re: error in compile
Date: Wed, 2 Mar 2005 15:57:09 +0100
User-agent: Mutt/1.4.2.1i

Hi

On Wed, Mar 02, 2005 at 07:38:56AM -0600, Paul F. Dietz wrote:
> Peter Wood wrote:
> 
> >>(let ((foo 'bar) (bar 'foo)) (defun fubar () (list bar foo)))
...
> >>(compile 'fubar)
> >
> >
> >LAMBDA-BLOCK-CLOSURE fell through ECASE expression.
> >Wanted one of (LAMBDA LAMBDA-BLOCK).
> >

> Your example isn't ANSI compliant.  See the page of CLHS for 'COMPILE':
> 
>     The consequences are undefined if the lexical environment
>     surrounding the function to be compiled contains any bindings
>     other than those for macros, symbol macros, or declarations.
> 
>       Paul
> 

Weird.  Why?

>From compile-file (CLHS)

       Any function definition that is processed by the compiler,
       including #'(lambda ...) forms and local function definitions
       made by flet, labels and defun forms, result in an object of
       type compiled-function.

Why is there a distinction made between compile and compile-file ?  I
believe I can expect the same definition in a file to be compiled to
machine code ?

Secondly, is it ansi for GCL to need closures like this one to be
wrapped in '(progn 'compile <form> )' for them to actually be compiled
to machine code when they are in a file being compiled with
#'compile-file ?  (setting compiler::*compile-ordinaries* to T has the
same effect).

given a file containing:

(defvar *fubar4* nil)

(defun fubar1 ()
  (let ((foo #'(lambda () 'foo)))
    foo))

(let ((foo 'bar) (bar 'foo))
  (defun fubar2 ()
    (list bar foo)))

(progn 'compile
       (let ((foo 'bar) (bar 'foo))
         (defun fubar3 ()
           (list bar foo))))
       

(let ((foo 'bar) (bar 'foo))
  (setf *fubar4* #'(lambda () (list bar foo))))

(defun test ()
  (list #'fubar1 #'fubar2 #'fubar3 *fubar4*))

If I compile and load this file and run (test), I get:

>(test)

(#<compiled-function FUBAR1>
 (LAMBDA-BLOCK-CLOSURE ((BAR FOO) (FOO BAR)) () () FUBAR2 ()
   (LIST BAR FOO))
 #<compiled-closure 093b06c8>
 (LAMBDA-CLOSURE ((BAR FOO) (FOO BAR)) () () () (LIST BAR FOO)))

>


Regards,
Peter




reply via email to

[Prev in Thread] Current Thread [Next in Thread]