[Ecls-list] with-accessors && declare

Matthew Mondor mm_lists at pulsar-zone.net
Thu Apr 8 02:22:05 UTC 2010


On Wed, 7 Apr 2010 20:46:45 +0200
Juan Jose Garcia-Ripoll <juanjose.garciaripoll at googlemail.com> wrote:

> On Tue, Apr 6, 2010 at 6:08 AM, Matthew Mondor <mm_lists at pulsar-zone.net>wrote:
> 
> > BTW, I noticed something else when doing these tests: If using
> > COMPILE-FILE on a file including OPTIMIZE DECLAIM form at the top, this
> > appears to be ignored.  If loading such a DECLAIM form with LOAD, or if
> > typing it at the REPL, then it is observed.  Is this expected?
> 
> 
> No. DECLAIM should take effect immediately in a compiled file, but only when
> it appears as a toplevel form. So, if you have a line
> 
> (LET (...) (DECLAIM ...)))
> 
> this will be skipped by the compiler. I have verified that DECLAIM does
> work. Using a simple file, foo.lsp
> 
> (declaim (optimize (safety 3) (debug 3)))
> 
> (defun foo (a)
>  (cos a))
> 
> the following session shows that the debug settings are properly used
> 
> > (load (compile-file "foo"))
> 
> ;;; Loading "/Users/jjgarcia/build/ecl/foo.fas"
> #P"/Users/jjgarcia/build/ecl/foo.fas"
> > (foo 'a)
> 
> In function COS, the value of the only argument is
>   A
> which is not of the expected type NUMBER
> 
> Available restarts:
> 
> 1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.
> 
> Broken at COS.
> >> :b
> 
> Backtrace:
>   > COS
>   > foo
>   > si:bytecodes [Evaluation of: (foo 'a)]
> 
> >> :p
> 
> Broken at FOO.
>  File: "foo.lsp" (Position #41)
> >> :v
> 
> Local variables:
>  A: A
> Special variables: none
> 
> But it may well be that the problem is with some specific declaim arguments.

That could be the case, what I see changing here with the same above test case is safety:


(declaim (optimize (speed 3) (safety 1) (debug 1)))

(defun foo (a)
  (cos a))


> (compile-file "/tmp/foo.lisp")

;;;
;;; Compiling /tmp/foo.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0
;;;
;;; Compiling (DEFUN FOO ...).
;;; End of Pass 1.
;;; Emitting code for FOO.
;;; Note:
;;;   Invoking external command:
;;;   gcc "-I/usr/local/ecl/include/"  -march=i686 -O2 -g -fPIC   -Dnetbsd -O -w -c "/tmp/foo.c" -o "/tmp/foo.o"
;;; 
;;; Note:
;;;   Invoking external command:
;;;   gcc -o "/tmp/foo.fas" -L"/usr/local/ecl/lib/" "/tmp/foo.o"  "-Wl,--rpath,/usr/local/ecl/lib/" -shared -g -g  -lecl  -lpthread   -lm 
;;; 
;;; Finished compiling /tmp/foo.lisp.
;;;
#P"/tmp/foo.fas"
NIL
NIL
> (load "/tmp/foo")

;;; Loading #P"/tmp/foo.fas"
#P"/tmp/foo.fas"
> (compile-file "/tmp/foo.lisp")

;;;
;;; Compiling /tmp/foo.lisp.
;;; OPTIMIZE levels: Safety=1, Space=0, Speed=3, Debug=1
;;;
;;; Compiling (DEFUN FOO ...).
;;; End of Pass 1.
;;; Emitting code for FOO.
;;; Note:
;;;   Invoking external command:
;;;   gcc "-I/usr/local/ecl/include/"  -march=i686 -O2 -g -fPIC   -Dnetbsd -O -w -c "/tmp/foo.c" -o "/tmp/foo.o"
;;; 
;;; Note:
;;;   Invoking external command:
;;;   gcc -o "/tmp/foo.fas" -L"/usr/local/ecl/lib/" "/tmp/foo.o"  "-Wl,--rpath,/usr/local/ecl/lib/" -shared -g -g  -lecl  -lpthread   -lm 
;;; 
;;; Finished compiling /tmp/foo.lisp.
;;;
#P"/tmp/foo.fas"
NIL
NIL
> 

Thanks,
-- 
Matt




More information about the ecl-devel mailing list