Re:Learn Lisp the Hard Way
by gre on Thursday July 10, 2014 @05:50PM
(#8017568)
The DSL for string formatting certainly doesn't look simple.
[ Parent
| on HN ]
Re:Learn Lisp the Hard Way
by ScottBurson on Thursday July 10, 2014 @06:06PM
(#8017650)
It's complex because it's powerful. ~A is the most common directive; it simply prints an object. '~{...~}' (braces) iterates over a list, applying the directives within it to the list elements. Within that construct, '~^' exits if the last element of the list has been consumed; it's used here to keep the separating space from being printed after the last element. '~@(...~)' (parens) capitalizes words in the output of the directives it contains, downcasing the non-initial character of each word.
So there's a lot more power here than in 'printf' control strings. If you find the more exotic notation unintuitive -- and you certainly wouldn't be alone -- you don't have to use it.
It's just disingenuous to say that LISP has extremely simple syntax and then show the DSL for format, which is anything but LISPy or simple.
It's disingenuous to claim a DSL is part of the language syntax. E.g. I would not consider the regex formatting specification as Python syntax. I mean, if we follow that line of thought, it's like saying Jinja is Python syntax.
If you're going to need to teach it for students to read and write programs in the wild than it's irrelevant whether it's 'part of the language syntax' or the ecosystem's syntax. 'Loop' is another one.
Lisp as an idea has a simple syntax but Common Lisp isn't even close to that platonic ideal.
Re:Learn Lisp the Hard Way
by ScottBurson on Thursday July 10, 2014 @07:44PM
(#8018054)
I don't know if it's disingenuous, but I'll agree that it may not be good marketing :-)
I am only recently a lisp user but honestly, how is the format function far from:
printf("something %s then %d finally %f!", "asd", 1, 1.2)
As mentioned, there is a loop built into format. Since lisp also has a (list) function eg: (list 'a 'b 'c 1) I still don't see an argument beyond familiarity with the C style printf syntax for why format is bad/unreadable.
There is a loop embedded in the lisp version.