Hacker News new | ask | show | jobs
by MadWombat 2342 days ago
Hmm... I see. (x y) is a list, g (x y) is a function call, f (...) is another function call, so f (g (x y)) is (f (g x y)) in regular LISP syntax. The syntax is parsed from innermost to outermost, so where is the ambiguity?
1 comments

(x y) is also a function call, because lisp always interprets the first position of a list as such unless you quote it:

  f (g ‘(x y))
But that changes the meaning of g from “a fn with two args” to “a fn with one arg that is a list.”

If your meaning is instead that function-outside notation cannot be mixed with s-exps, I.e. you have to choose one mode or the other, then I think you’re right that there’s no ambiguity here (and no need to quote the args above). I suspect you would lose the power of macros, and may not be able to use existing ones, but I don’t write them so I’m not sure.

Below are some Clojure expressions with standard and then function-outside versions. I quickly found that I wanted to go back to attached() parens() for those, because that seems more readable to my eyes than having () them () spaced out. I’d never choose this option though, it took all of an afternoon to get used to lisp syntax, and I find it to be more readable now than c-style languages.

  (let [a 1 b 2] (+ a b))
  let ([a 1 b 2] + (a b))
  let( [a 1 b 2] +(a b))

  (apply + (range 10))
  apply(+ range(10))

  (defn my-fn [x] (* x x))
  defn (my-fn [x] *(x x))
Eh... you are still stuck with LISP. We are talking about an alternate syntax where (x y) is not a function call.