gcl-devel
[Top][All Lists]
Advanced

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

[Gcl-devel] Re: tertium non datur: ANSI help


From: Camm Maguire
Subject: [Gcl-devel] Re: tertium non datur: ANSI help
Date: 14 Apr 2006 11:12:01 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Greetings!

Robert Boyer <address@hidden> writes:

> I bet Camm and Jeff are right on target.  Yes, "the point of
> functional evaluation" must refer to the activities that the
> function FUNCTION engages in, presumably even compilation
> in some cases in some Lisps, including GCL.  When doing such
> a compilation, the OPTIMIZE/SAFETY quality would naturally
> into play.
> 
> Here's an odd, dimly related passage from ANSI, re: COERCE:
> 
>   For the form (coerce x 'function), where x is a lambda expression, the value
>   of the optimize quality safety in the global environment at the time the
>   coerce is executed applies to the resulting function.
> 
> The transcript below may show an infinitely obscure
> OPTIMIZE/SAFETY3 bug in GCL.  Whenever the GCL compiler is
> compiling a call to FUNCTION, turning some lambda expression
> or interpreted function into compiled code that will, we
> hope, run faster, the compiler needs to worry about what the
> current lexical value of SAFETY is.  Or does the SAFETY=0
> setting when the function 'foo' is being compiled permit
> 'foo' to return an unsafe function, even though the (inner)
> function definition (flet) and the function evaluation in
> question (the execution of FUNCTION when foo is run) is
> performed in a lexical SAFETY=3 environment and the CAR in
> question is within a lexical SAFETY=3.  Still confused.  But
> thanks a lot.
> 

Good question.  Just wanted to note that

(defun foo ()
 (declare (optimize (safety 3)))
 (flet ((foo (x) (declare (optimize (safety 3)))(car x))) (function
 foo)))

does what you want at present.

Take care,

> Bob
> 
> -------------------------------------------------------------------------------
> 
> % cat foo.lisp
> (defun foo ()
>  (declare (optimize (safety 3)))
>  (flet ((foo (x) (car x))) (function foo)))
> 
> % xg
> GCL (GNU Common Lisp)  2.7.0 ANSI    Apr 12 2006 10:03:41
> 
> >(load (compile-file "foo.lisp"))
> 
> ;; Compiling foo.lisp.
> ;; End of Pass 1.  
> ;; End of Pass 2.  
> ;; OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3, 
> (Debug quality ignored)
> ;; Finished compiling foo.o.
> Loading /v/filer2/boyer/foo.o
> start address -T 0xab45428 Finished loading /v/filer2/boyer/foo.o
> 272
> 
> >(declaim (optimize (safety 3)))
> 
> NIL
> 
> >(funcall (foo) 'a)
> 
> NIL
> 
> ; should signal an error, no?
> 
> 
> 

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