-
Notifications
You must be signed in to change notification settings - Fork 85
Deviations from JavaScript
null-a edited this page Oct 7, 2016
·
9 revisions
For example, this works as expected:
var f = function() { return g() };
var g = function() { return 42 };
f(); // => 42
But wrapping f
breaks things:
var id = function(x) { return x; };
var f = id(function() { return g() });
var g = function() { return 42 };
f(); // "Uncaught ReferenceError: g is not defined"
See #61.
In JS, the consequent and alternate blocks of an if
statement don't introduce new scopes. They do in WebPPL:
if (true){
var x = 1;
} else {
var x = 2;
}
x // "Uncaught ReferenceError: x is not defined"
See #103.
Higer-order functions written in WebPPL don't work when passed primitive JS functions. Perhaps less importantly, higher order JS primitives won't work when passed WebPPL functions.
See #30.
Functions can only be created with function expressions.
See #2.
WebPPL functions sometimes (always?) implicitly return the value of the last expression evaluated:
var f = function() {
if (false) {
0
} else {
1
}
};
f() // => 1