proposal-block-params
proposal-block-params copied to clipboard
Completion value suggestion
From @erights:
One of the alternatives worth exploring here is to "the last expression without a semicolon" to take as the return value. For example:
let evens = foreach ([1, 2, 3, 4]) do (item) {
let even;
if (item % 2 == 0) {
even = item;
}
// returns item if even, undefined otherwise
even
// important to note that if a ";" gets added,
// undefined is returned
}
Crucial to this suggestion is that it would apply to do expressions as well. Anywhere we might be tempted to use completion value, we should use this instead.
The absent semicolon above would be syntax, not a missing semicolon to be repaired by ASI. Since we're only talking about new syntactic forms, we have that option.
Credit where due: Inspired by Rust's syntax.