3 ms·
As a former CL dabbler I didn't mind the square brackets in let but I really liked the use of them for vector and curly braces for map. To me bringing two usefu
by justinhj 9y ago
As a former CL dabbler I didn't mind the square brackets in let but I really liked the use of them for vector and curly braces for map. To me bringing two useful data structures beyond lists into the language syntax felt very powerful and simple.
- kbp 9y agoCommon Lisp does have syntax for vectors, they're written #(1 2 3). It doesn't have literal syntax for hash tables, but it's a trivial read-macro if you can't live without it (although alists have some other nice properties like easy shadowing/popping of bindings, and the kind of associations you would want to write as literals are generally small enough that their O(n) lookup isn't a problem). CLTL2 gives a rationale for using #(...) instead of [...] for vectors: Many people have suggested that brackets be used to notate vectors, as [a b c] instead of #(a b c). This notation would be shorter, perhaps more readable, and certainly in accord with cultural conventions in other parts of computer science and mathematics. However, to preserve the usefulness of the user-definable macro-character feature of the function read, it is necessary to leave some characters to the user for this purpose. Experience in MacLisp has shown that users, especially implementors of languages for use in artificial intelligence research, often want to define special kinds of brackets. Therefore Common Lisp avoids using brackets and braces for any syntactic purpose.