5 ms·
Lisp uses the same number of parens as most languages per call – the only thing that's different is whether the paren goes before or after the first part of the
by kenferry 12y ago
Lisp uses the same number of parens as most languages per call – the only thing that's different is whether the paren goes before or after the first part of the call.
(print "hello")
vs
print("hello")
So to the extent Lisp is paren-heavy, it's more a stylistic thing. Lisp programmers tend to chain up calls more.
- rtpg 12y agoWhat about a paren-less calling mechanism? main = putStrLn "hello"
- eru 12y agoPossible, and nice. But you lose the ability to easily specify a variable number of arguments.
- Sanddancer 12y agoShell languages seem to do just fine using spaces to easily specify a variable number of arguments.
- eru 12y agoYes. I forgot to mention that Haskell also supports partial application. Shell doesn't, so that's easier. And that's just talking about syntax. The type system complicates matters further.
- jakub_h 12y agoWell, there's always the Smalltalk approach.
- UnquietTinkerer 12y ago(-b + sqrt(b*b - 4*a*c)) / (2*a) (/ (+ (- b) (sqrt (- (* b b) (* 4 a c)))) (* 2 a)) It does depend on your use case.
- yogthos 12y agoThat's why we have macros http://liebke.github.io/incanter/infix-api.html http://liebke.github.io/incanter/infix-api.html https://github.com/incanter/incanter/blob/master/modules/incanter-core/src/incanter/infix.clj https://github.com/incanter/incanter/blob/master/modules/inc...
- kazinator 12y agoLisp only has infix macros so that we can say "we have that". Nobody in their right mind uses this stuff in production code. It just overcomes objections. "Oh, if I start using Lisp, there is be a way to use infix, should I really need it". Ten years and six Lisp project later, you still haven't used the infix stuff; the situation never comes.
- yogthos 12y agoClearly you didn't even look at the links provided. :)
- jakub_h 12y ago> Nobody in their right mind uses this stuff in production code. You sure about that? I thought the lispy approach was generally pragmatic - you use what you deem handy for your application. It this weren't the case, there would be little need for macros in the first place. I can very well imagine, say, a scientific or engineering application that would share a common infix parser for both user-provided expressions (in the UI, to be more friendly to non-lispers) and heavy math lifting in the source code.
- ChristianBundy 12y agoYour second line hurts me inside.
- ynniv 12y agohttp://srfi.schemers.org/srfi-105/srfi-105.html http://srfi.schemers.org/srfi-105/srfi-105.html {-(b) + {sqrt((b * b) - (4 * a * c)) / (2 * a)}}
- eru 12y ago> Lisp uses the same number of parens as most languages per call [...] Indeed. If you want less parens, use Haskell or Forth.
- kazinator 12y ago> Lisp uses the same number of parens as most languages per call Furthermore, Lisp uses zero parentheses for grouping in order to override precedence. These parentheses don't exist in Lisp. In print(2/(2+4)), we actually have two kinds of parentheses, because two different grammar rules use the same token. C has even more parentheses. The parentheses in for (;;) are not the same as those in 2/(2+4) which are not the same as those in (double) p, which are not the same as those in p(42). Lisp has parentheses that do one darn thing in the read syntax---at least when they are not literal as in "(" or #\(.