How to add a feature to *features* ?

How to add a feature to *features* ?

Post by jurgen_def » Mon, 04 Sep 2006 22:11:05

I looked into the CLtL and the CLHS, but I did not find anything about

What I would like to do is some conditional compilation to include
(declaim (optimize (safety 0))) when a feature is present or not.

Can this be done like this, or are there other possibilities to reach
this goal ?

Currently, I do this via a makefile, and I build targets with separate
names, like components.fasl and components_o.fasl.



How to add a feature to *features* ?

Post by Bill Atkin » Mon, 04 Sep 2006 23:20:13

(pushnew :myfeature *features*)

Try ASDF instead of makefiles.


How to add a feature to *features* ?

Post by Ken Tilto » Mon, 04 Sep 2006 23:21:44

(pushnew :my-feature *features*)


How to add a feature to *features* ?

Post by Pascal Bou » Tue, 05 Sep 2006 00:40:56

"Bill Atkins" < XXXX@XXXXX.COM > writes:

You can also push a non keyword on *features* to avoid any collision
with other packages.

(defpackage "MYSELF" (:use "COMMON-LISP") (:export "MY-FEATURE"))
(pushnew 'myself:my-feature *features*)
#+myself:my-feature (print "I'm myself!")
#-myself:my-feature (print "I'm somebody else!")
#+my-feature (print "This is not myself!")
#-my-feature (print "This might be me!")


"I'm myself!"
"This might be me!"

__Pascal Bourguignon__
You're always typing.
Well, let's see you ignore my
sitting on your hands.

How to add a feature to *features* ?

Post by jurgen_def » Tue, 05 Sep 2006 15:13:03

I know about asdf, but I currently don't have the time to learn it, and
I know Makefiles. It is on my to do list however.



How to add a feature to *features* ?

Post by John Thing » Tue, 05 Sep 2006 21:15:49

On Sun, 03 Sep 2006 15:11:05 +0200, jurgen_defurne

May I add that you are using Lisp wrong.
Lisp is designed the way it is to allow incremental compilation
on a per function basis.

Write a function.
Test it.
Compile it.

Move on keeping the state space.
The real difference is that any global data strutures you create persist.
So you can then write another function using the generated data without
having to produce it again.

The reason you need to recompile a file is because of macro's.
A macro change can have global consequences.
Thus it needs to change the code and replace the expansions of the macro's
all files that use it. If you think ASDF is too complicated defsystem is a
place to start.

Using Opera's revolutionary e-mail client:

How to add a feature to *features* ?

Post by Pierre THI » Tue, 05 Sep 2006 23:00:25

Le Sun, 03 Sep 2006 23:13:03 -0700, jurgen_defurne a crit:

You *do* have 15 minutes available... You don't need much more to use

Nowhere man
OpenPGP 0xD9D50D8A

How to add a feature to *features* ?

Post by jurgen_def » Wed, 06 Sep 2006 03:51:38

Maybe this is something personal. I NEED to first get my design right
on paper, even of only one function. This is because I can't otherwise
concentrate on my development.

So, I first design my function by writing a plain language description,
then from that, I derive the structure I need, and then the basic
operations needed on that structure. I do this by using a wordprocessor
to lay down my design, and emacs to code. I have done development in
the past using literate programming, but I like using a wordprocessor
more, because it is easier to refrain myself from writing code when I
know my design is not complete yet.

If this is finished, I design and create a test fixture, together with
a bunch of tetstvectors, for the functions I need. Then I compile and
run the tests, adapting my code until it runs well.

Besides, if you do development like you told me, do you a) end up with
a directory full of small compiled function files or b) with one
sourcefile that you will have to recompile and reload if you want to go
on with its development ?



How to add a feature to *features* ?

Post by Rainer Jos » Wed, 06 Sep 2006 05:18:04

m 04.09.2006 20:51 Uhr schrieb "jurgen_defurne" unter

This is a typical problem. You really need to relearn the tools
when you switch to Lisp. Otherwise you are wasting a lot
of time. And you think you have no time to learn the tools.
Sharpen your axe first before you are continue to use it.

There are several different development styles you can use,
but typically you would use one that is interactive.
If you need to go back to batch programming you should
have a reason.

A typical development style is to use a Lisp environment,
open the text editor and work from there. SLIME/Emacs/SBCL
would be one combination, but it could also be
ELI/Emacs/Allegro CL, just LispWorks, just Allegro CL,
Hemlock/CMUCL, FRED/MCL, ...

Open a text file. Write your forms there and evaluate from
there. In SLIME/Emacs press c-h m to describe the mode and
scroll down in the help for the Slime commands.
c-m-x or c-c c-c would be typical. Place your cursor
on some form and evaluate or compile it. The most
simple setup is to have a function and some tests for it.
Change the function, compile it and evaluate the tests.
Write the next function, some tests and switch between
changing the function and the tests until they do
what you want. Usually you would put related functions
in one file in some package you define. You would not
recompile/reload the file unless you need to. You would
just execute/compile individual forms.

Or to expand a bit on it. Read about bottom-up design.

Say, you want to write a function to start a motor
when you have enough fuel.

fun start motor
unless enough fuel
fill fuel in tank
when enough fuel
start motor

add some parentheses

(defun start-motor (car)
(unless (enough-fuel-p car)
(fill-fuel-in-tank car)
(when (enough-fuel-p car)
(start-motor car)))

c-c c-c compiles it

Write some code to execute it.


(defparameter *my-car* (make-instance 'benz))
(start-motor *my-car*)


Then place your cursor on the forms you want to execute and eval them.
You can also mark a region and execute the region.
If you have your test suite, call it from here.

After you made your code working, clean up the file.
Remove unused code. Add documentation, probably move the tests
to some other file, ...
Then compile your file in a fresh Lisp, see of there are some
warnings/errors. Change your code so that there are no
warnings and errors and the code compiles/executes

and so on.

You may check out also this video:

There I show some simple development with LispWorks
using one Editor window and one Listener window.
Code gets written and compiled in the Editor and tried
out in the Listener. Ignore the example and
see the use of the incremental compiler from
the editor, the read-eval-print-loop in the
Listener, DESCRIBE, PPRINT, *, ... and more.


How to add a feature to *features* ?

Post by jurgen_def » Thu, 07 Sep 2006 04:17:56

Allright, I tried to do it. However, I already get stuck in the begin

I have emacs, slime and sbcl installed under Debian. When I open my
already existing file where I want to continue development, the through
slime invoked sbcl compilation fails.

The file I am busy on, first defines a package "DIGITAL-COMPONENTS"
and then does its definitions (structures and functions).

I got two kinds of problems in this combination.

When I (load) this just from a command line session, I have no
proble,s. When I try to (load) the file in slime (.lisp or .fasl does
not matter), I get an error about a redefinition of output in the sbcl
compiler package or something. Yes, there is a defstruct called output
in my file.

The second problem is when I try to compile the file in the emacs
buffer. Then I get a whole bunch of warnings that my structure
accessors are undefined functions.

Any thoughts anybody ?



How to add a feature to *features* ?

Post by Pascal Bou » Thu, 07 Sep 2006 06:52:14

"jurgen_defurne" < XXXX@XXXXX.COM > writes:

Wait, I'm going to fetch my cristall ball...

__Pascal Bourguignon__

"You can tell the Lisp programmers. They have pockets full of punch
cards with close parentheses on them." -->

How to add a feature to *features* ?

Post by jurgen_def » Thu, 07 Sep 2006 13:20:38

Yeah, I know, I know, I should have posted my output.

The thing is : did SBCL + EMACS + SLIME work for anyone here who uses
this combination out of the box or not ? I read the slime manual, but
it only shows the functions available and some possibilities for

Good morning and have a nice day.


How to add a feature to *features* ?

Post by evan » Thu, 07 Sep 2006 13:40:28

works great for me :).

I run on Ubuntu Dapper with the following versions:
sbcl 1:
emacs 21.4a-3ubuntu2
slime-2.0 (development version: svn revision 380)


How to add a feature to *features* ?

Post by jurgen_def » Fri, 08 Sep 2006 02:55:19

Yeah well, on this particular machine I forgot to add the slime
initialisation code to my .emacs file.