Re:Improving Programming Language Performance
by lifthrasiir on Sunday December 10, 2023 @03:06AM
(#38589982)
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`.
[ Parent
| on HN ]
Re:Improving Programming Language Performance
by MaxBarraclough on Sunday December 10, 2023 @06:22AM
(#38590815)
Other 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.)
Re:Improving Programming Language Performance
by lifthrasiir on Sunday December 10, 2023 @06:33AM
(#38590855)
I'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.
Re:Improving Programming Language Performance
by aidenn0 on Sunday December 10, 2023 @11:57AM
(#38592927)
You 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;
}
}