Lowell wrote:
> I am having trouble finding any information on the forms #- and #+. Can
> someone point me in the right direction?
Kinda like C's #ifdef.
If Lisp (the reader, actually) comes across #+shhhh in the source, it
looks in the global param *features* for an instance of 'shhhh (or
:shhhh, not sure what's going on there--symbol-name match?). Anyway...
If 'shhhh is a member of the *features* list, the next form (atom or
list) is seen by the compiler, if not it is as if the form were not
there. So be careful:
(if (bad-stuff)
#+shhhh (print 'big-trouble)
(print 'AOK))
Assuming there is no feature 'shhhh, you'll get AOK when bad-stuff says
true.
#-testing is "unless". The code gets included if 'testing is /not/ a
feature.
Normally one uses this to make development code code away for releases:
#-production-release (worry-wart-validation)
And as you can see, it is a handy way to comment out multi-line forms:
#+naahhhhh (print (list 'this-huge-expression
'that-huge-expression))
--
kenny tilton
clinisys, inc
http://www.tilton-technology.com/
---------------------------------------------------------------
"Career highlights? I had two. I got an intentional walk from
Sandy Koufax and I got out of a rundown against the Mets."
-- Bob Uecker
Kenny Tilton wrote:
> Normally one uses this to make development code code away for releases:
sorry, I got distracted. I meant to say one sees it a lot to
conditionalize code meant to run under different OSes or Lisp
implementations, when you run into incompatibilities.
eg, My current RoboCup project needed some #+cmucl and #+allegro
conditionalization to deal with CLOS and socket differences.
--
kenny tilton
clinisys, inc
http://www.tilton-technology.com/
---------------------------------------------------------------
"Career highlights? I had two. I got an intentional walk from
Sandy Koufax and I got out of a rundown against the Mets."
-- Bob Uecker
Kenny Tilton <·······@nyc.rr.com> writes:
> eg, My current RoboCup project needed some #+cmucl and #+allegro
^^^^^^^
ITYM #+cmu
> conditionalization to deal with CLOS and socket differences.
-dan
--
http://www.cliki.net/ - Link farm for free CL-on-Unix resources
Kenny Tilton <·······@nyc.rr.com> wrote:
+---------------
| #-testing is "unless". The code gets included if 'testing is /not/ a
| feature.
|
| Normally one uses this to make development code code away for releases:
|
| #-production-release (worry-wart-validation)
|
| And as you can see, it is a handy way to comment out multi-line forms:
|
| #+naahhhhh (print (list 'this-huge-expression
| 'that-huge-expression))
+---------------
Just a reminder that we had a long thread a while back [pretty long ago,
actually, since Erik Naggum was a major contributor to the thread], in
which it was pointed out that the frequently-used #+NIL for "commenting-out"
code was technically unsafe, and #+NAAHHHHH is even more unsafe. How do
you know you won't someday load a hifty little package you got from the
"National Aerospace and Avionics Hardware Hackers and Handy Heap Helpers",
and suddenly find :NAAHHHHH on the features list??!?
Fortunately, as noted in that long-ago thread, there is an absolutely
safe alternative. The features syntax includes NOT/AND/OR expressions,
and those operators -- specifically AND and OR -- obey the "usual" Lisp
rules for null argument lists of the special forms ADN and OR. That is,
(AND) as a feature expression is *always* true, thus #+(AND) can always
be used to unconditionally enable code; likewise, #-(AND) can always be
used to unconditionally disable it.
So ever since then, I've been using *only* (AND) for those kinds of
things:
#-(and) ;;XXX Turn this off for now.
(print (list 'this-huge-expression
'that-huge-expression))
or:
#+(and) ;;XXX Temporarily turn on for debugging.
(format t ...)
Consistently using *only* (AND) with either #+ or #- has the advantage
that it's easier to remember what's enabled and disabled. Instead of
the inverted logic of #+NEVER-DEFINED to mean "off", you have #-(AND).
The minus is always used for "off", and the plus is always used for "on".
Simple. Easy.
[Thanks, Erik!]
-Rob
-----
Rob Warnock, PP-ASEL-IA <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
Rob Warnock wrote:
> Kenny Tilton <·······@nyc.rr.com> wrote:
> +---------------
> | #-testing is "unless". The code gets included if 'testing is /not/ a
> | feature.
> |
> | Normally one uses this to make development code code away for releases:
> |
> | #-production-release (worry-wart-validation)
> |
> | And as you can see, it is a handy way to comment out multi-line forms:
> |
> | #+naahhhhh (print (list 'this-huge-expression
> | 'that-huge-expression))
> +---------------
>
> Just a reminder that we had a long thread a while back [pretty long ago,
> actually, since Erik Naggum was a major contributor to the thread], in
> which it was pointed out that the frequently-used #+NIL for "commenting-out"
> code was technically unsafe, and #+NAAHHHHH is even more unsafe. How do
> you know you won't someday load a hifty little package you got from the
> "National Aerospace and Avionics Hardware Hackers and Handy Heap Helpers",
> and suddenly find :NAAHHHHH on the features list??!?
Easy. never use anyone else's code. Re-invent every wheel. :)
Seriously, tho, nice point. It's great how simple newby questions here
on c.l.l expand rapidly into grad level seminars.
We have a bunch of Lisp newby's on the lisp-nyc RoboCup sig, and I am
horrified to learn they do not read c.l.l. I'm working on that, tho.
--
kenny tilton
clinisys, inc
http://www.tilton-technology.com/
---------------------------------------------------------------
"Career highlights? I had two. I got an intentional walk from
Sandy Koufax and I got out of a rundown against the Mets."
-- Bob Uecker
Kenny Tilton wrote:
> We have a bunch of Lisp newby's on the lisp-nyc RoboCup sig, and I am
> horrified to learn they do not read c.l.l. I'm working on that, tho.
Is it worth a lisp newbe's (who has buckley's of getting to NY this
year) time to read that? And if so, how?
---
Tristan McLeay
reverse the ordering of the segments.
@com.yahoo wrote:
> Kenny Tilton wrote:
>
>> We have a bunch of Lisp newby's on the lisp-nyc RoboCup sig, and I am
>> horrified to learn they do not read c.l.l. I'm working on that, tho.
>
>
> Is it worth a lisp newbe's (who has buckley's of getting to NY this
> year) time to read that? And if so, how?
By c.l.l. I meant comp.lang.lisp, so yer doin' fine.
Don't forget to sign the newby register:
http://www.cliki.net/The%20RtLS%20by%20Switch%20Year
2003 needs your help catching 2002. Of course none of the lisp-nyc
newbies have done /that/ either. <sigh>
:)
--
kenny tilton
clinisys, inc
http://www.tilton-technology.com/
---------------------------------------------------------------
"Career highlights? I had two. I got an intentional walk from
Sandy Koufax and I got out of a rundown against the Mets."
-- Bob Uecker
Kenny Tilton wrote:
> By c.l.l. I meant comp.lang.lisp, so yer doin' fine.
Err... of course. :)
> Don't forget to sign the newby register:
>
> http://www.cliki.net/The%20RtLS%20by%20Switch%20Year
http://www.cliki.net/Tristan%20Alexander%20McLeay's%20Road%20to%20Lisp
> 2003 needs your help catching 2002. Of course none of the lisp-nyc
> newbies have done /that/ either. <sigh>
Six more to go till they're equal, assuming my maths is up to the task :)
Tristan.
On Sat, 16 Aug 2003 08:45:14 -0500, ····@rpw3.org (Rob Warnock) wrote:
> [Thanks, Erik!]
To give credit where credit is due, this idea actually came from Paul
F. Dietz:
<http://www.google.com/groups?threadm=3D660F51.3BEE3D56%40dls.net>
Edi.
Edi Weitz <···@agharta.de> wrote:
+---------------
| On Sat, 16 Aug 2003 08:45:14 -0500, ····@rpw3.org (Rob Warnock) wrote:
|
| > [Thanks, Erik!]
|
| To give credit where credit is due, this idea actually came from Paul
| F. Dietz: <http://www.google.com/groups?threadm=3D660F51.3BEE3D56%40dls.net>
+---------------
Oh, yes, of course! Thanks, Paul!
[And thanks for digging out the proper reference, Edi.]
-Rob
p.s. I had just remembered Erik being heavily-involved in the thread,
especially the parallels between (and) & (or) and (*) & (+).
-----
Rob Warnock, PP-ASEL-IA <····@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607
Kenny Tilton <·······@nyc.rr.com> writes:
> If Lisp (the reader, actually) comes across #+shhhh in the source, it
> looks in the global param *features* for an instance of 'shhhh (or
> :shhhh, not sure what's going on there--symbol-name match?).
It compares symbol identity. When #+ or #- reads the feature
expression, it temporarily makes the KEYWORD package current so
that #+shhhh is read the same as #+:shhhh. Symbols in other
packages can be used with explicit prefixes.
Kalle Olavi Niemitalo wrote:
> Kenny Tilton <·······@nyc.rr.com> writes:
>
>
>>If Lisp (the reader, actually) comes across #+shhhh in the source, it
>>looks in the global param *features* for an instance of 'shhhh (or
>>:shhhh, not sure what's going on there--symbol-name match?).
>
>
> It compares symbol identity. When #+ or #- reads the feature
> expression, it temporarily makes the KEYWORD package current so
> that #+shhhh is read the same as #+:shhhh. Symbols in other
> packages can be used with explicit prefixes.
Wow.
[1] CELLS(16): (push 'cells42 *features*)
(CELLS42 :ALLEGRO-IDE :COMMON-GRAPHICS :ACL-SOCKET :HIPER-SOCKET
:PROFILER :MULTIPROCESSING :FLAVORS :LITTLE-ENDIAN ...)
[1] CELLS(17): (export 'cells42)
T
[1] CELLS(18): (in-package :cello)
#<The CELLO package>
[1] CLO(19): *features*
(CELLS42 :ALLEGRO-IDE :COMMON-GRAPHICS :ACL-SOCKET :HIPER-SOCKET :PROFILER
:MULTIPROCESSING :FLAVORS :LITTLE-ENDIAN ...)
[1] CLO(20): (print 1 #-cells42 2)
Error: `2' is not of the expected type `STREAM'
[condition type: TYPE-ERROR]
No wonder I always use keywords for features. :)
Thanks for the info.
--
kenny tilton
clinisys, inc
http://www.tilton-technology.com/
---------------------------------------------------------------
"Career highlights? I had two. I got an intentional walk from
Sandy Koufax and I got out of a rundown against the Mets."
-- Bob Uecker
In article <············@mughi.cs.ubc.ca>, Lowell <······@cs.ubc.ca>
wrote:
> I am having trouble finding any information on the forms #- and #+. Can
> someone point me in the right direction?
See http://www.lispworks.com/reference/HyperSpec/Body/02_dhq.htm and http://www.lispworks.com/reference/HyperSpec/Body/02_dhr.htm
Pascal