(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
-Peter
--
Peter Seibel pe...@javamonkey.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
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.
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.)
> 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! |
/ / `-----------------------'
( -. |
| ) |
(`-. '--.)
`. )----'
> 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?
> 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
Neither. I use (character " ").
--
__Pascal_Bourguignon__
http://www.informatimago.com/
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
> 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.
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
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
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
> 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/
> [1] Well, just remember to type *two* spaces after the backslash...
One space is enough; the open-parenthesis is a terminating macro character.
> 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.
> 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
> 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