Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been teaching Lisp to a friend and one of the things he likes best is the syntax. He likes that there is only one kind of punctuation, the parenthesis.


Well, that's not really the case. Parentheses are the main type of bracket used in most Lisps(which can be nicer than having [], (), and {}, some of which frequently have entirely different meanings depending on what syntactic context they are used in(for example, languages which use "{}" for both blocks and dictionaries, or "[]" for both list/array construction and indexing)). However, in Common Lisp for example,(with many present in other lisps) there's also the quote, the semicolon, the double quote for strings, the backquote and comma for partial quoting, #\ for character literals, #' for functions, #( ) for vectors, #* for bitvectors, #: for uninterned symbols, #. for read-time evaluation, #B for binary rational literals, #O for octal, #X for hexadecimal, #R for arbitrary bases, #C for complex numbers, #A for arrays, #S for structures, #P for paths, #n=foo and #n# for labeling objects for back-reference, #+ and #- for read-time testing for available features, and #| |# for comments. And of course, Common Lisp supports reader macros, so you could end up with a lot of potential syntactic punctuation.

Of course, most of the time, you won't need most of that syntax. And, it does have the advantage of mostly being defined in Common Lisp and being fairly consistent.

But parentheses are definitely not the only punctuation in Lisp.


But parenthesis are the only required punctuation. Any of those others you mentioned can be equivalently expressed by parenthetical expressions. Homoiconicity is preserved.


I don't think that that is true, at least not for Common Lisp.

How do you express any of the following constructs using only parentheses and symbols?

#:foo #.(foo) #+ FOO (bar) #- FOO (baz)

For the original Lisp, parentheses and symbols were all that was necessary. For more recent derivatives, that is not necessarily the case.


Well, Packages are a reader-hack, so you couldn't express them with parenthesis, although you should be able to IMHO.

#+FOO (bar)

This could almost be: (when (member FOO features) (bar)) Just wrap it in an eval-when.


Yeah, but in Java, you need four kinds of punctuation right off the blocks.


You get a similar sort of experience with concatenative languages too.


I didn't even know that such a thing existed until today, here is the other thread:

http://news.ycombinator.com/item?id=1373046




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: