4 ms·
Unreadable? Personally, I think that Lisp has the clearest possible syntax - because it basically doesn't have any. It's just straight ASTs - something that I h
by golergka 10y ago
Unreadable? Personally, I think that Lisp has the clearest possible syntax - because it basically doesn't have any. It's just straight ASTs - something that I have to visualize myself in other languages wich have more syntax sugar.
- tromp 10y agoLisp has the minimal syntax for lists: (a b c d) where other languages require separating commas, but Haskell has minimal syntax for function application: f x y z with no parenthesis needed. (Technically, this is a triple application ((f x) y) z, masked by the convention of application being a left-associative binary operator.)
- chirau 10y agoHow would you write f((x y)z) in Haskell?
- deleted 10y ago[deleted]
- scriptdevil 10y agof $ x y $ z Basically, f $ x = f x and is applied with lowest operator precedence (0) and is right associative. Therefore, f $ x y $ z = f (x y $ z) = f((x y) z)
- tromp 10y agof (x y z)
- vq 10y agoIf by (x y) you mean x(y) then I would write it like this: f (x y) z
- kazinator 10y agoThat is "minimally punctuated syntax". What we want is a "minimal correspondence between written syntax and the AST"; that is what is really meant by "Lisp has minimal syntax". What you have there is loaded with ambiguity that has to be resolved by semantics. And after the dust settles, you're left without variadic functions. Partial evaluation and currying are very valuable techniques. They are still succinct if there is a visible, explicit partial application operator to denote a function that is constructed by binding arguments around an expression.
- wtetzner 10y agoRight, Haskell's function application syntax is more "minimal" that Lisp's, at least in the simple case. But golergka said that Lisp's syntax is the clearest, not the smallest. And while that's probably something that depends on one's knowledge and past experience, I think there's something to it. The parens mean that it's unambiguous, and there is very little work on the reader's part to figure out where an expression begins and ends. There's no operator precedence to keep in mind, no special whitespace rules, etc. It's about as minimal as you can get while still being completely explicit about syntactic constructs.
- golergka 10y ago> but Haskell has minimal syntax for function application: > f x y z The question is, is it the _only_ syntax that Haskell offers and that the full language is built upon?
- lmm 10y agoIt makes e.g. arithmetic expressions look rather awkward.
- golergka 10y agoThat's if you choose to think abiut them as arithmetic expressions and not function applications. If you work with arithmetic expressions a lot, you should probably use appropriate domain language - in fact, you can build it in Lisp itself.
- lmm 10y agoYou can write a reader macro (in lisps that permit them, otherwise you've got no hope) but that's just lisp-speak for "program that parses strings". A language where you can use infix notation within the language is much nicer.