Re:Six years of professional Clojure development
by jeofken on Thursday May 06, 2021 @05:02AM
(#27060728)
It’s just like C or JS but the first paren goes to the left of the function name.
[ Parent
| on HN ]
Re:Six years of professional Clojure development
by Blikkentrekker on Thursday May 06, 2021 @06:38AM
(#27061295)
With function calls, yes.
What makes it different is that syntactic constructs are also expressed with the same syntax and there is no special syntax, so control flow constructs use a syntax similar to function calls.
This is particularly exuberant in Arc where what in many languages would be:
if (<cond1>) {
<then expr1>
} else if (<cond2>) {
<then expr2>
} else if (<cond3>) {
<then expr3>
} else {
<else expr>
}
Would instead be: (if
<cond1> <then expr1>
<cond2> <then expr2>
<cond3> <then expr3>
<else expr>)
Note the complete lack of syntax beyond a keyword having 7 arguments in order, which many find nonconsecutive to reading, and also error prone as accidentally making a typo can completely change the meaning of the program.It is thus that most Lisps have somewhat more redundant syntax:
(cond
[<cond1> <then expr1>]
[<cond2> <then expr2>]
[<cond3> <then expr3>]
(else <else expr>))
Personally, I wouldn't mind that a mandatory `->` be required in between the conditions and the expression to further guard against accidental typos. I find that redundancy in syntax guards against accidental mistakes, though I have nothing against the parentheses and in fact favor them.
Re:Six years of professional Clojure development
by bionhoward on Thursday May 06, 2021 @08:01AM
(#27061960)
Pattern matching in rust:
match x {
<cond1> => <expr1>,
<cond2> => <expr2>,
<cond3> => <expr3>,
_ => <expr>,
}
let message = match maybe_digit {
Some(x) if x < 10 => process_digit(x),
Some(x) => process_other(x),
None => panic!(),
};
Seems useful. Python's getting match soon too!https://doc.rust-lang.org/reference/expressions/match-expr.h...
Re:Six years of professional Clojure development
by kaliszad on Thursday May 06, 2021 @05:53PM
(#27069481)
Clojure specifically doesn't have the bracket wrapper around condition-expression pairs but syntax highlighting/ formatting considers it and aligns stuff nicely. I don't think, it is a problem that it basically is a list or function call with arguments. I do think, adding `->` just like that would be a problem because it would be very inconsistent with the syntax of Clojure.