Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Style question: #\ versus #\Space

13 views
Skip to first unread message

Martin Pomije

unread,
Nov 14, 2003, 5:00:32 PM11/14/03
to
In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
good example of this is on p. 65.

(defun second-word (str)
(let ((p1 (+ (position #\ str) 1)))
(subseq str p1 (position #\ str :start p1))))

Or in Fig. 4.2, p. 67

(defun constituent (c)
(and (graphic-char-p c)
(not (char= c #\ ))))

I came across #\Space while reading through the Hyperspec (thanks
Kent) and find it to be much easier to read. However, Paul Graham's
experience makes me wonder if there isn't something that I'm missing.

Which one do you prefer?

Peter Seibel

unread,
Nov 14, 2003, 5:03:44 PM11/14/03
to
use...@MartinPomije.eiomail.com (Martin Pomije) writes:

#\Space

-Peter

--
Peter Seibel pe...@javamonkey.com

Lisp is the red pill. -- John Fraser, comp.lang.lisp

Barry Margolin

unread,
Nov 14, 2003, 5:40:24 PM11/14/03
to
In article <m3ekwal...@javamonkey.com>,

Peter Seibel <pe...@javamonkey.com> wrote:
>use...@MartinPomije.eiomail.com (Martin Pomije) writes:
>
>> In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
>> good example of this is on p. 65.
>>
>> (defun second-word (str)
>> (let ((p1 (+ (position #\ str) 1)))
>> (subseq str p1 (position #\ str :start p1))))
>>
>> Or in Fig. 4.2, p. 67
>>
>> (defun constituent (c)
>> (and (graphic-char-p c)
>> (not (char= c #\ ))))
>>
>> I came across #\Space while reading through the Hyperspec (thanks
>> Kent) and find it to be much easier to read. However, Paul Graham's
>> experience makes me wonder if there isn't something that I'm missing.
>>
>> Which one do you prefer?
>
>#\Space

Me too. It's more readable, and much less likely to be ruined accidentally
by editing.

--
Barry Margolin, barry.m...@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

Christopher C. Stacy

unread,
Nov 14, 2003, 5:56:19 PM11/14/03
to
>>>>> On Fri, 14 Nov 2003 22:40:24 GMT, Barry Margolin ("Barry") writes:

Barry> In article <m3ekwal...@javamonkey.com>,


Barry> Peter Seibel <pe...@javamonkey.com> wrote:
>> use...@MartinPomije.eiomail.com (Martin Pomije) writes:
>>
>>> In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
>>> good example of this is on p. 65.
>>>
>>> (defun second-word (str)
>>> (let ((p1 (+ (position #\ str) 1)))
>>> (subseq str p1 (position #\ str :start p1))))
>>>
>>> Or in Fig. 4.2, p. 67
>>>
>>> (defun constituent (c)
>>> (and (graphic-char-p c)
>>> (not (char= c #\ ))))
>>>
>>> I came across #\Space while reading through the Hyperspec (thanks
>>> Kent) and find it to be much easier to read. However, Paul Graham's
>>> experience makes me wonder if there isn't something that I'm missing.
>>>
>>> Which one do you prefer?
>>
>> #\Space

Barry> Me too. It's more readable, and much less likely to be ruined
Barry> accidentally by editing.

I've been programming in Lisp forever, and didn't even realize that
you could do #\ in CL! (And I wouldn't want to ever see it.)

Thomas F. Burdick

unread,
Nov 14, 2003, 6:21:17 PM11/14/03
to
use...@MartinPomije.eiomail.com (Martin Pomije) writes:

> In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
> good example of this is on p. 65.

Unfortunately, I don't think Paul Graham is a very good source for
micro-style in Common Lisp. For style-in-the-large, yes, but he's
quite clear that although he loves Lisp, he has little love for the
specific design decisions of Common Lisp. This means that in some
ways, his style fights against the language. Keep going through the
book, for sure, just if you find yourself thinking, "that looks a
little too concise, almost cryptically so," it probably is.

--
/|_ .-----------------------.
,' .\ / | No to Imperialist war |
,--' _,' | Wage class war! |
/ / `-----------------------'
( -. |
| ) |
(`-. '--.)
`. )----'

Darius

unread,
Nov 14, 2003, 6:34:08 PM11/14/03
to
On 14 Nov 2003 15:21:17 -0800

t...@fallingrocks.OCF.Berkeley.EDU (Thomas F. Burdick) wrote:

> use...@MartinPomije.eiomail.com (Martin Pomije) writes:
>
> > In "ANSI Common Lisp" Paul Graham uses #\ for the space character.
> > A good example of this is on p. 65.
>
> Unfortunately, I don't think Paul Graham is a very good source for
> micro-style in Common Lisp. For style-in-the-large, yes, but he's
> quite clear that although he loves Lisp, he has little love for the
> specific design decisions of Common Lisp. This means that in some
> ways, his style fights against the language. Keep going through the
> book, for sure, just

if you find yourself thinking, "that looks a
> little too concise, almost cryptically so," it probably is.

When is that advice -not- true?

Wolfhard Buss

unread,
Nov 14, 2003, 7:07:25 PM11/14/03
to

* Martin Pomije writes:

> In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
> good example of this is on p. 65.
>

> (defun second-word (str)
> (let ((p1 (+ (position #\ str) 1)))
> (subseq str p1 (position #\ str :start p1))))
>
> Or in Fig. 4.2, p. 67
>
> (defun constituent (c)
> (and (graphic-char-p c)
> (not (char= c #\ ))))

:


> Which one do you prefer?

Neither.

--
Signature under construction

Pascal Bourguignon

unread,
Nov 14, 2003, 9:08:23 PM11/14/03
to
use...@MartinPomije.eiomail.com (Martin Pomije) writes:

Neither. I use (character " ").


--
__Pascal_Bourguignon__
http://www.informatimago.com/

Kenny Tilton

unread,
Nov 14, 2003, 9:30:47 PM11/14/03
to

Christopher C. Stacy wrote:

> I've been programming in Lisp forever, and didn't even realize that
> you could do #\ in CL! (And I wouldn't want to ever see it.)
>

Yeah, but now we can claim white space is significant and win over all
the Pythonistas.

:)

--
http://tilton-technology.com

Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film

Your Project Here! http://alu.cliki.net/Industry%20Application

Thomas F. Burdick

unread,
Nov 14, 2003, 10:07:49 PM11/14/03
to
cst...@dtpq.com (Christopher C. Stacy) writes:

> I've been programming in Lisp forever, and didn't even realize that
> you could do #\ in CL! (And I wouldn't want to ever see it.)

Not only can you do #\ in CL, but even #\ , in which case you might
not see it, depending on the column it starts in.

Tayss

unread,
Nov 15, 2003, 12:42:24 AM11/15/03
to
use...@MartinPomije.eiomail.com (Martin Pomije) wrote in message news:<90ac4ec2.03111...@posting.google.com>...

> I came across #\Space while reading through the Hyperspec (thanks
> Kent) and find it to be much easier to read. However, Paul Graham's
> experience makes me wonder if there isn't something that I'm missing.
>
> Which one do you prefer?

If you want a book ref, Guy Steele's cltl2 i/o chapter mentions that
the name is to be preferred with nonprinting characters. (And he
claims #\Space is more stylish than #\space. ;) It hasn't worn off
that I still think it's pretty cool to name characters... and it gives
rise to that pun where people walk around with their first names in
their sigs like:
#\Tayssir

Alexander Schreiber

unread,
Nov 15, 2003, 12:45:39 PM11/15/03
to
Martin Pomije <use...@MartinPomije.eiomail.com> wrote:
>In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
>good example of this is on p. 65.
>
>I came across #\Space while reading through the Hyperspec (thanks
>Kent) and find it to be much easier to read. However, Paul Graham's
>experience makes me wonder if there isn't something that I'm missing.
>
>Which one do you prefer?

I prefer #\Space because it makes its purpose clear: "Thou shalt make
thy program's purpose and structure clear to thy fellow man [..],
for thy creativity is better used in solving problems than in creating
beautiful new impediments to understanding."[0]

Regards,
Alex.
[0] Shamelessly stolen from Henry Spencers "Ten Commandments for C
Programmers"
--
"Opportunity is missed by most people because it is dressed in overalls and
looks like work." -- Thomas A. Edison

Rob Warnock

unread,
Nov 15, 2003, 10:08:04 PM11/15/03
to
Thomas F. Burdick <t...@fallingrocks.OCF.Berkeley.EDU> wrote:
+---------------
| use...@MartinPomije.eiomail.com (Martin Pomije) writes:
| > In "ANSI Common Lisp" Paul Graham uses #\ for the space character...
...
| ...if you find yourself thinking, "that looks a little too concise,

| almost cryptically so," it probably is.
+---------------

Here's my ultimate example of excessively cryptic (and dangerous) style:

> (defmacro \ (args &body body)
`(lambda ,args ,@body))
| |
>

Now you can write all kinds of concise[1] anonynmous functions:

> (mapcar (\ (x) (* x 3)) '(1 2 3))
(3 6 9)
> (position 4 '(5 6 7 8) :test (\ (x y) (= x (- y 3))))
2
>

;-} ;-}


-Rob

[1] Well, just remember to type *two* spaces after the backslash...

-----
Rob Warnock <rp...@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607

Pascal Bourguignon

unread,
Nov 16, 2003, 1:04:26 AM11/16/03
to
rp...@rpw3.org (Rob Warnock) writes:

> Thomas F. Burdick <t...@fallingrocks.OCF.Berkeley.EDU> wrote:
> +---------------
> | use...@MartinPomije.eiomail.com (Martin Pomije) writes:
> | > In "ANSI Common Lisp" Paul Graham uses #\ for the space character...
> ...
> | ...if you find yourself thinking, "that looks a little too concise,
> | almost cryptically so," it probably is.
> +---------------
>
> Here's my ultimate example of excessively cryptic (and dangerous) style:
>
> > (defmacro \ (args &body body)
> `(lambda ,args ,@body))

> [1] Well, just remember to type *two* spaces after the backslash...

Actually only one is needed, because ( is a terminating macro char.
http://www.lisp.org/HyperSpec/Body/sec_2-1-4.html

[2]> (defun a(a)'a)
A
[9]> (defmacro \ (args &body body)`(lambda ,args ,@body))
| |
[13]> (funcall(\ (a b)(+ a b))1 2)
3
[14]>


--
__Pascal_Bourguignon__
http://www.informatimago.com/

Kalle Olavi Niemitalo

unread,
Nov 16, 2003, 8:53:46 AM11/16/03
to
rp...@rpw3.org (Rob Warnock) writes:

> [1] Well, just remember to type *two* spaces after the backslash...

One space is enough; the open-parenthesis is a terminating macro character.

Kent M Pitman

unread,
Nov 16, 2003, 2:02:12 PM11/16/03
to
rp...@rpw3.org (Rob Warnock) writes:

> Thomas F. Burdick <t...@fallingrocks.OCF.Berkeley.EDU> wrote:
> +---------------
> | use...@MartinPomije.eiomail.com (Martin Pomije) writes:
> | > In "ANSI Common Lisp" Paul Graham uses #\ for the space character...
> ...
> | ...if you find yourself thinking, "that looks a little too concise,
> | almost cryptically so," it probably is.
> +---------------
>
> Here's my ultimate example of excessively cryptic (and dangerous) style:
>
> > (defmacro \ (args &body body)
> `(lambda ,args ,@body))
> | |
> >
>
> Now you can write all kinds of concise[1] anonynmous functions:
>
> > (mapcar (\ (x) (* x 3)) '(1 2 3))
> (3 6 9)
> > (position 4 '(5 6 7 8) :test (\ (x y) (= x (- y 3))))
> 2
> >
>
> ;-} ;-}

It's perhaps of historical interest that in Maclisp we used / for what
CL uses \ for. That means to divide you had to use //. One of the
most common things was to get a bug report from a newbie to Maclisp
saying that something like | 5| or | X| was an undefined operator, and
asking what was that error message all about.

A few moment's thought may lead you to figure out why we eventually
went with backslash as the syntactic quoting character like most other
languages did.

vsync

unread,
Nov 16, 2003, 3:55:41 AM11/16/03
to
use...@MartinPomije.eiomail.com (Martin Pomije) writes:

> I came across #\Space while reading through the Hyperspec (thanks
> Kent) and find it to be much easier to read. However, Paul Graham's
> experience makes me wonder if there isn't something that I'm missing.
>
> Which one do you prefer?

I use #\Space because '#\ ' seems to mess up ILISP's parser sometimes.

--
vsync
http://quadium.net/
Banking on my hopes that whoever grades this will just look at the
pictures, I drew an exponential through my noise. I believe the
apparent legitimacy is enhanced by the fact that I used a complicated
computer program to make the fit.
-- http://www.cs.wisc.edu/~kovar/hall.html

Tyro

unread,
Nov 17, 2003, 9:33:00 AM11/17/03
to
At the moment I am studying Paul Graham's book in which he uses #\ .
However, I disagree with Graham on this matter and replace his #\
with #\Space. In my code I use #\Space because it is clear.

Duane Rettig

unread,
Nov 17, 2003, 12:24:01 PM11/17/03
to
a...@usenet.thangorodrim.de (Alexander Schreiber) writes:

> Martin Pomije <use...@MartinPomije.eiomail.com> wrote:
> >In "ANSI Common Lisp" Paul Graham uses #\ for the space character. A
> >good example of this is on p. 65.
> >
> >I came across #\Space while reading through the Hyperspec (thanks
> >Kent) and find it to be much easier to read. However, Paul Graham's
> >experience makes me wonder if there isn't something that I'm missing.
> >
> >Which one do you prefer?
>
> I prefer #\Space because it makes its purpose clear: "Thou shalt make
> thy program's purpose and structure clear to thy fellow man [..],
> for thy creativity is better used in solving problems than in creating
> beautiful new impediments to understanding."[0]

Another reason to prefer #\Space is because that is what the lisp tends
to print out. This is, of course, a style question only, and there is
really no one answer, but often, when I am not sure how I should arrange
my code, I either let my editor or my lisp break the tie by stating its
opinion.

--
Duane Rettig du...@franz.com Franz Inc. http://www.franz.com/
555 12th St., Suite 1450 http://www.555citycenter.com/
Oakland, Ca. 94607 Phone: (510) 452-2000; Fax: (510) 452-0182

0 new messages