Closed domenic closed 7 years ago
why should it be any different from a Block. Alternative the semantics of preexisting constructs within micro contexts just adds spec/implementation complexity and make a language harder to learn and use.
Do you mean whether vars hoist outside of a do
block?
The purpose of do
-expressions is to minimize friction (aka refactoring hazards, aka inequivalences) for fine-grained refactoring (aka TCP). For example:
function f() {
let tmp;
{
var result = foo();
tmp = bar(result);
}
baz(tmp);
return result;
}
can be refactored to:
function f() {
baz(do {
var result = foo();
bar(result)
});
return result;
}
just adds spec/implementation complexity and make a language harder to learn and use.
Agreed.
In short: the plan is that vars are allowed inside of do
-expressions and hoist to the nearest enclosing function/module/script, as per usual.
Great, this might be something to add to the readme then, as I thought it was something of a controversy... @ajklein
Thought it'd be worth opening a tracking issue for this problem, which I believe is fairly well-known. Looking forward to hearing what the solution is (I have no idea myself).