Better to use “and” or “in” when chaining “let” statements?

前端 未结 4 1745
情歌与酒
情歌与酒 2021-02-19 09:43

I realize this is probably a silly question, but...

If I\'m chaining a bunch of let statements which do not need to know each other\'s values, is it

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-19 10:21

    It's the same as the difference between let and let* in Lisp, I believe. let* (similar in functionality to the in..in.. structure - the second structure in your question) is sometimes used to hide imperative programming since it guarantees sequential execution of expressions (see what Paul Graham had to say about let* in On Lisp).

    So, I'd say the former construct is better. But the truth is, I think the latter is more common in the Ocaml programs I have seen. Probably just easier to use in letting one build on previously named expressions.

提交回复
热议问题