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: Camm Maguire
Subject: Re: [Gcl-devel] Re: error in compile
Date: 04 Mar 2005 17:54:59 -0500
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

Peter Wood <address@hidden> writes:

> 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 ?
> 

I'm not quite sure, but I'd like to state that within the confines of
the ANSI spec, I'd like to homogenize the two in GCL to the extent
possible.  This can easily appear confusing.

> 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)))
> 
> >

Don't you really just want

(let ((a 1) (b 2)) 
        (setf *fubar4* (compile nil `(lambda () 
                (let ((foo ,a) (bar ,b)) (list bar foo))))))

Take care,
 


> 
> 
> Regards,
> Peter
> 
> 
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/gcl-devel
> 
> 
> 

-- 
Camm Maguire                                            address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah




reply via email to

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