Skip to main content
gamedev.net
🔒 Locked

Reading Lisp

Started by choffstein Sep 5, 2006 at 7:11 PM 7 replies 1.3k views
Original Post
choffstein
choffstein
In my quest to learn more languages, I have begun taking a look at Lisp. I normally learn in three ways: 1) tutorials, 2) testing, 3) reading examples. My issue? All the examples I look at, I got lost so quick in the forest of parenthesis. Do you experienced Lisp programmers have any advice on how I can get used to looking at all the parenthesis and unwinding the meaning? I have experience with functional languages, but Lisp just confuses me. Thanks
smitty1276
smitty1276
Well, when you know what the functions are that you are looking at, it makes it a bit easier to read. So it will get better with time. Still, I prefer to do what most people don't and at least try to structure/format the code so that it is readable... and use comments...

; Check some condition here... blah blah blah(cond  ; If the first two list elements are equal, do whatever...  ; Otherwise, do whatever  ((eq (car l) (cadr l))         (somefunc-here some-arg))  (T                             (some-default-func-here some-arg)))


That sort of thing. A lot of people don't bother with superfluous whitespace.

EDIT: Fixed rogue parenthesis at end of cond.

[Edited by - smitty1276 on September 5, 2006 8:27:18 PM]
smitty1276
smitty1276
Definately (what Brandon said) * 2. It's worth installing cygwin with xemacs for doing lisp.
choffstein
choffstein
Alright. That sure does help. Thanks guys.
smitty1276
smitty1276
Quote:
Original post by Anonymous Poster
Formatting lisp like that is a surefire way to:
1) Never be able to read any other lispers' code.
2) Guarantee no lisper will ever want to read yours.

There is a standard way of formatting lisp, with only minor deviations. Use it.

I didn't claim to be a lisp expert. That's just how I like to format mine in the extremely rare cases that I must use lisp. But, now that you mention it, I would probably put the closing parenthesis at the end of the previous line, not on its own line. I'm not sure where that came from.

But whether the extra whitespace is normally used or not, I feel very strongly that formatting this way is inarguably superior. [grin] I would be interested in hearing an explanation of how NO formatting (aside from indentation) is easier to read.



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.