Lisp HUG Maillist Archive

File-global compilation options

Hi,

I'm trying to understand how to use proclaim and declaim to set the file-wide compilation options. However I can't see in LW compiler output what the options take place.

For example when I have in my file:
(defpackage py.path
  (:use :cl))

(in-package py.path)
(proclaim '(optimize (safety 0) (speed 3)))

and try to compile the files using either Ctrl-c Ctrl-k or (compile-file "path-to-file"),
in the compiler output I see the same
;;; Compiling file C:\Sources\pypath\py-path.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is  on
;;; Cross referencing is on


Why my declarations do not reflected in this output? How can I understand what they are actually taking place?

Br,
/Alexey

Re: File-global compilation options

Proclaim on the top level will  have a runtime effect. Use declaim which wraps a proclaim in an eval-when to get compilation time effects. 

-- 
__Pascal Bourguignon__

> Le 6 juil. 2016 à 15:46, Alexey Veretennikov <txm.fourier@gmail.com> a écrit :
> 
> Hi,
> 
> I'm trying to understand how to use proclaim and declaim to set the file-wide compilation options. However I can't see in LW compiler output what the options take place.
> 
> For example when I have in my file:
> (defpackage py.path
>   (:use :cl))
> 
> (in-package py.path)
> (proclaim '(optimize (safety 0) (speed 3)))
> 
> and try to compile the files using either Ctrl-c Ctrl-k or (compile-file "path-to-file"),
> in the compiler output I see the same
> ;;; Compiling file C:\Sources\pypath\py-path.lisp ...
> ;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
> ;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
> ;;; Source level debugging is on
> ;;; Source file recording is  on
> ;;; Cross referencing is on
> 
> 
> Why my declarations do not reflected in this output? How can I understand what they are actually taking place?
> 
> Br,
> /Alexey 
> 


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: File-global compilation options

Hi Alexey,

I asked a similar question to LW support, and here is the answer I got from Martin Simmons :

> If you want to change the settings for a specific function, then use declare:
> 
> (defun testfunction ()
>   (declare (optimize (speed 3) (safety 0) (debug 0)))
>   (let* ((n 10000)
>          (a (make-array n)))
>   (dotimes (i n)
>     (setf (aref a i) i))))
> 
> If you want to change the setting for a whole file, then use declaim:
> 
> (declaim (optimize (speed 3) (safety 0) (debug 0)))
> 
> (defun testfunction ()
>   (let* ((n 10000)
>          (a (make-array n)))
>   (dotimes (i n)
>     (setf (aref a i) i))))
> 
> (defun testfunction2 () ...)
> 
> Note that LispWorks will still display Safety = 3 etc in both cases, because
> that is the initial setting at the start of the file.
> 
> You can change the initial setting by calling proclaim (or declaim) before
> compiling the file, but that is not recommended, except within a build script
> used in batch mode, because it will affect all compilation.

It looks like it’s what you are looking for.

Best,

Dimitri

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: File-global compilation options

Hi,

2016-07-06 16:46 GMT+03:00 Alexey Veretennikov <txm.fourier@gmail.com>:
Hi,

I'm trying to understand how to use proclaim and declaim to set the file-wide compilation options. However I can't see in LW compiler output what the options take place.

For example when I have in my file:
(defpackage py.path
  (:use :cl))

(in-package py.path)
(proclaim '(optimize (safety 0) (speed 3)))

and try to compile the files using either Ctrl-c Ctrl-k or (compile-file "path-to-file"),
in the compiler output I see the same
;;; Compiling file C:\Sources\pypath\py-path.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 1
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is  on
;;; Cross referencing is on


Why my declarations do not reflected in this output?
Probably because the output shows the global compilation settings, rather than proclaimed by you.

How can I understand what they are actually taking place?
Probably, by disasembling?

Re: File-global compilation options

Thanks! Now I understand it.


Dimitri Bouche <Dimitri.Bouche@ircam.fr> writes:

> Hi Alexey,
>
> I asked a similar question to LW support, and here is the answer I got from
> Martin Simmons :
>
>> If you want to change the settings for a specific function, then use declare:
>> 
>> (defun testfunction ()
>>   (declare (optimize (speed 3) (safety 0) (debug 0)))
>>   (let* ((n 10000)
>>          (a (make-array n)))
>>   (dotimes (i n)
>>     (setf (aref a i) i))))
>> 
>> If you want to change the setting for a whole file, then use declaim:
>> 
>> (declaim (optimize (speed 3) (safety 0) (debug 0)))
>> 
>> (defun testfunction ()
>>   (let* ((n 10000)
>>          (a (make-array n)))
>>   (dotimes (i n)
>>     (setf (aref a i) i))))
>> 
>> (defun testfunction2 () ...)
>> 
>> Note that LispWorks will still display Safety = 3 etc in both cases, because
>> that is the initial setting at the start of the file.
>> 
>> You can change the initial setting by calling proclaim (or declaim) before
>> compiling the file, but that is not recommended, except within a build script
>> used in batch mode, because it will affect all compilation.
>
> It looks like it’s what you are looking for.
>
> Best,
>
> Dimitri

-- 
Br,
/Alexey

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:32 UTC