- Series of macros which help users optimize the conditional jumps in a inner loop
- The interface is similar to the continuation, so I call it as `compile-time continuation?. Everything is implemented in compile-time so theres no performance drawbacks in run-time
- Extensible syntaxes and helper macros for other implementers of libraries, especially for the macro writers or the heavy lambda-lovers. Provides a standardized way to minimize the number of condition check
- It does not use
symbol-macroletanymore, which means it can be used with
- This library is not well maintained now. Please (?) don't use it.
- I think I will reerite it with recursive-macroexpansion.
The condition checking is done only once.
(ql:quickload :iterate) (use-package :iterate) (defun test0 (flag) (with-inner (body) (iter (for i from 0 to 5) (print i) (inner (body) (if flag (body (princ "loop on")) (body (princ "loop off"))))))) INNER-CONDITIONAL-TEST> (test0 t) 0 loop on 1 loop on 2 loop on 3 loop on 4 loop on 5 loop on
Concepts and API
Removing conditional jumps in loops are one of the easiest way to optimize the loop. The number of checks should be minimized, and the checking variables in a smaller loop may well be a large bottleneck. Yet, some code would yield a bad-looking result of that optimization, since the semantics of the code best fits the code which has conditional jumps in a smaller loop. Luckily, Common Lisp has macros, which provides the ability to walk on and modify the code tree. So we can keep the code clean and at the same time get a faster result.
For more details, see Concepts and API (https://github.com/guicho271828/inner-conditional/blob/master/concepts-and-api.org)
Use with your own library
If you write a macro which expands to a code which always checks a certain dynamic variable then this library may help you write an extension which minimizes the number of checks in the expanded code.
For more details, see Use with your own library (https://github.com/guicho271828/inner-conditional/blob/master/use-with-your-own-library.org)
The effect of this library may seem trivial, but still I try to show you an optimization results with trivial examples. Any other result reports are welcome! Because I don't came up with other truly-performance-sensitive examples.
For more details, see Optimization Results (https://github.com/guicho271828/inner-conditional/blob/master/opt-results.org)
This library is at least tested on implementation listed below:
- SBCL 1.1.2 on X86-64 Linux 3.2.0-39-generic (author's environment)
Also, it depends on the following libraries:
Jonathan Amsterdam's iterator/gatherer/accumulator facility
Alexandria is a collection of portable public domain utilities.
- CL-ANNOT by Tomohiro Matsuyama
Python-like Annotation Syntax for Common Lisp
- CL-SYNTAX by m2ym
Reader Syntax Coventions for Common Lisp and SLIME
- Optima by m2ym
Optimized Pattern Matching Library for Common Lisp
- First grab the code with
git clone git://github.com/guicho271828/inner-conditional.git
- Put it in your local-project folder
- open slime REPL
(ql:quickload :inner-conditional)and the library will be installed along with the dependencies
- Masataro Asai (email@example.com)
Copyright (c) 2013 Masataro Asai (firstname.lastname@example.org)
Licensed under the LLGPL License.
- Masataro Asai