proposal-block-params icon indicating copy to clipboard operation
proposal-block-params copied to clipboard

Completion value suggestion

Open samuelgoto opened this issue 8 years ago • 1 comments

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
}

samuelgoto avatar Nov 30 '17 22:11 samuelgoto

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.

erights avatar Nov 30 '17 22:11 erights