Dear all,
happy and successful New Year to you all.
Now, to WebPPL. To my astonishment I saw two lets in ch.07 of the ebook Cognition models. More precisely it was in a code box explaining the MH-algorithm.
I always saw that "var" was used for the purpose of definitions. "let" was not in the WebPPL docs so I looked how "let" was defined in JS.
I read that "var" has no block scope but "let" has since ES2015. I tried an example from W3School. This revealed that "let" in WebPPL has **no** block scope:
Here's the code snippet:
var x = 10;
// Here x is 10
print("x1 = " + x)
{
let x = 2;
// Here x is 2
print("x2 = " + x)
}
// Here x is 10
print("x3 = " + x)
WebPPL's output is: