(if (empty? x)
foo
bar)
edit: lolz. failed at example. fixed.foo is the result of if x is empty, and you can tell it is not a function call because it has no parens. Whitespace is merely a style consideration, as it is in C++ or Java.
There are ways to save time/trouble within the language. For instance, in Clojure
(foo (bar (baz (quux x))))
can be rewritten as ((comp foo bar baz quux) x)
There's also stuff like apply, ->, and ->> in Clojure, which have similar purposes (flattening out the nesting a bit). And for anything particularly syntactically onerous, you can always add sugar with macros.Ultimately syntax is more about ease than it is about power or simplicity. I think it's worthwhile to try to look beyond that into what the code is saying rather than how it's saying it. You have to do this anytime you learn a significantly different language anyway, right?
Ideal:
if (empty? x)
foo
bar
Less ideal: (if (empty? x)
foo
bar)
The clojure comp shortcut looks good to me, but why even need the outside parens if it was the only line in that block? (comp foo bar baz quux) x
Ideally, that should be valid as well. I know this kind of reduction won't work in a lot of cases, but I appreciate syntax sugaring like this where I can get it.As it stands now, the trade-off is some unfamiliarity and discomfort up front for rather elegant consistency for the entire time you use the language. When you're optimizing for the people who'll use the language, the former is a lot less significant. :)
One thing worth noting is that Clojure does introduce constructs which use square brackets, braces, etc. It's a little nicer to use brackets for grouping, in lieu of parens for lists or declaring function params.
The elegance seems to come from having a simpler parser, and one less thing to explain to people when they're learning the lanuage. As a user of a language and not a developer of a parser, the first doesn't concern me and the second should be trumped by long-term concerns. Using significant whitespace to eliminate syntax is elegant in its own way as well.
Again, maybe this is just because I'm not a lisper, but keeping implicit parens that follow a well-established pattern should be a trivial mental task for a developer. Could you provide a piece of lisp code as a contra example?
I appreciate when languages don't make me insert/edit/move over/count/deal with/etc. more characters than necessary. Maybe there's a good vim setup to do that already - that would go a long way to alleviate my concerns.
[0]: https://github.com/santoshrajan/lispyscript/blob/master/exam...