Skip to content

Using Alternative Optimizer

Javier Olaechea edited this page Oct 3, 2015 · 2 revisions

The basic design of Trivia it to separate the pattern expansion and optimization. Thus, Trivia comes with :trivial optimizer by default, an optimizer that returns the given patterns immediately.

To switch the optimizer, like the one provided in https://github.com/guicho271828/trivia.balland2006, use the command (in-optimizer optimizer-name).

(in-optimizer :trivial)
(defun a (x)
  (match x
    ((list :a :b y)   'list-third)
    ((vector :a y :b) 'vector-second))))

(in-optimizer :balland2006)
;; change the optimizer and recompile the code!
(defun a (x)
  (match x
    ((list :a :b y)   'list-third)
    ((vector :a y :b) 'vector-second))))

The easiest way to use this balland2006 optimizer is to call (ql:quickload :trivia.balland2006.enabled). It will automatically run (in-optimizer :balland2006).

Clone this wiki locally