Skip to content

About optimize proclaimation #16

@llibra

Description

@llibra

CL-PATTERN has optimize proclaimation.
It causes unwanted change of compile policy at load-time.

> (declaim (optimize (speed 1) debug safety))
NIL
> (ccl:declaration-information 'optimize)
((SPEED 1) (SAFETY 3) (COMPILATION-SPEED 1) (SPACE 1) (DEBUG 3))
> (ql:quickload :cl-pattern)
To load "cl-pattern":
  Load 1 ASDF system:
    cl-pattern
; Loading "cl-pattern"

(:CL-PATTERN)
> (ccl:declaration-information 'optimize)
((SPEED 3) (SAFETY 3) (COMPILATION-SPEED 1) (SPACE 1) (DEBUG 3))

There are some better ways for optimize declaration:

;; Use declare in each functions
(defun f ()
  (declare (optimize speed))
  ...)

;; Use locally at top level and surround function definitions with it
(locally (declare (optimize speed))
  (defun x () ...)
  (defun y () ...))

;; Proclaim optimize declaration at only compile-time
(eval-when (:compile-toplevel)
  (proclaim '(optimize speed)))

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions