js-slang
js-slang copied to clipboard
Stepper: steps appear as if capturing happens
The stepper doesn't distinguish variables properly when they are already referring to functions:
https://share.sourceacademy.org/svqdz
function h(f, x) {
function h(g, x) {
return x <= 1 ? 1 : 3 * g(f, x - 1);
}
return x <= 1 ? 1 : 2 * f(h, x - 1);
}
h(h, 5);
Here, the two h
in h(h(5 - 1))
refer to different values:
The fact that they are different becomes clear here:
Note that only one of the
h
are highlighted as being substituted.
The stepper should make clear that the two h
are different by appropriately renaming one of them.
(This is called alpha-renaming, and already done properly for other cases.)