From: jurgen_defurne
Subject: How to add a feature to *features* ?
Date: 
Message-ID: <1157289065.062482.307980@m73g2000cwd.googlegroups.com>
I looked into the CLtL and the CLHS, but I did not find anything about
this.

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.

Regards,

Jurgen

From: Bill Atkins
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157293212.963323.168010@m79g2000cwm.googlegroups.com>
jurgen_defurne wrote:
> I looked into the CLtL and the CLHS, but I did not find anything about
> this.
>
> 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.
>
> Regards,
>
> Jurgen

(pushnew :myfeature *features*)

Try ASDF instead of makefiles.
From: Pascal Bourguignon
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <87irk5lzzr.fsf@thalassa.informatimago.com>
"Bill Atkins" <·········@gmail.com> writes:
> jurgen_defurne wrote:
>> How to add a feature to *features* ?
>> I looked into the CLtL and the CLHS, but I did not find anything about
>> this.
>
> (pushnew :myfeature *features*)

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!")

prints:

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


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
You're always typing.
Well, let's see you ignore my
sitting on your hands.
From: jurgen_defurne
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157350383.767109.4040@h48g2000cwc.googlegroups.com>
Bill Atkins wrote:
> jurgen_defurne wrote:
> > I looked into the CLtL and the CLHS, but I did not find anything about
> > this.
> >
> > 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.
> >
> > Regards,
> >
> > Jurgen
>
> (pushnew :myfeature *features*)
>
> Try ASDF instead of makefiles.

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.

Thanks,

Jurgen
From: Pierre THIERRY
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <pan.2006.09.04.14.00.25.129521@levallois.eu.org>
Le Sun, 03 Sep 2006 23:13:03 -0700, jurgen_defurne a écrit :
> I know about asdf, but I currently don't have the time to learn it,

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

Timely,
Nowhere man
-- 
···········@levallois.eu.org
OpenPGP 0xD9D50D8A
From: Ken Tilton
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <ZxBKg.2239$8l.992@newsfe08.lga>
  (pushnew :my-feature *features*)

kt
From: John Thingstad
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <op.tfcscnpapqzri1@pandora.upc.no>
On Sun, 03 Sep 2006 15:11:05 +0200, jurgen_defurne  
<··············@pandora.be> wrote:

> I looked into the CLtL and the CLHS, but I did not find anything about
> this.
>
> 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.
>
> Regards,
>
> Jurgen
>

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  
in
all files that use it. If you think ASDF is too complicated defsystem is a  
good
place to start.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
From: jurgen_defurne
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157395898.320396.161680@m73g2000cwd.googlegroups.com>
John Thingstad wrote:
>
> 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.
>

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 ?

Regards,

Jurgen
From: Rainer Joswig
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <C122569C.4F535%joswig@lisp.de>
Am 04.09.2006 20:51 Uhr schrieb "jurgen_defurne" unter
<··············@pandora.be> in
························@m73g2000cwd.googlegroups.com:

> John Thingstad wrote:
>> 
>> 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.
>> 
> 
> 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 ?

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
cleanly.

and so on.

You may check out also this video:
http://cl-http.org:8002/mov/dsl-in-lisp.mov

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.
From: jurgen_defurne
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157483876.572982.265140@m73g2000cwd.googlegroups.com>
Allright, I tried to do it. However, I already get stuck in the begin
phase.

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 ?

Regards,

Jurgen
From: Pascal Bourguignon
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <873bb67zht.fsf@thalassa.informatimago.com>
"jurgen_defurne" <··············@pandora.be> writes:

> Allright, I tried to do it. However, I already get stuck in the begin
> phase.
>
> 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 ?

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

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"You can tell the Lisp programmers.  They have pockets full of punch
 cards with close parentheses on them." --> http://tinyurl.com/8ubpf
From: jurgen_defurne
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157516438.484688.42850@m73g2000cwd.googlegroups.com>
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
customising.

Good morning and have a nice day.

Jurgen
From: evan
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157517627.905843.25930@i3g2000cwc.googlegroups.com>
jurgen_defurne wrote:
> 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
> customising.

works great for me :).

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

Evan
From: jurgen_defurne
Subject: Re: How to add a feature to *features* ?
Date: 
Message-ID: <1157565319.880131.233910@m73g2000cwd.googlegroups.com>
Yeah well, on this particular machine I forgot to add the slime
initialisation code to my .emacs file.

Regards,

Jurgen