3 ms·
I'm reasonably sure that it is modeled after JS `let`, so there should be a notion of implicit scopes defined by, for example, `fun`.
by lifthrasiir 3y ago
I'm reasonably sure that it is modeled after JS `let`, so there should be a notion of implicit scopes defined by, for example, `fun`.
- MaxBarraclough 3y agoOther way round. They're implementing a language of the LISP family, which tend to use let this way. LISP languages originated around 1960. The use of let then caught on in other languages, including OCaml and Haskell, and eventually JavaScript. (It's possible some language other than LISP was the first to use let, but my suspicion is it was LISP.) https://en.wikipedia.org/wiki/Lisp_(programming_language) https://en.wikipedia.org/wiki/Lisp_(programming_language)
- lifthrasiir 3y agoI'm specifically saying about `let` syntax in this particular language. LISP and related languages also have `let` with substantially different semantics, but it's evident that it wouldn't make much sense given current examples.
- aidenn0 3y agoYou must be right. I actually didn't know JS had a "let" (which is different from "var" in that it is block scoped rather than function scoped). It's also quite different from the let in most Lisps, in that it does not establish a new lexical block. Playing with it, the binding is scoped to the entire block, but the assignment happens in statement order so that e.g. the following will be an error, rather than logging either "1" or "2" both of which there could be arguments for: { let x = 1; { console.log(x); let x = 2; } }