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

Syntactic look-a-likes?

Open rwaldron opened this issue 8 years ago • 3 comments

function f(message, callback) {
  console.log(message);
  callback();
}

let message = "The Message";

// A
let o = {
  f(message) {
    console.log(message);
  }
};

// B
o: {
  f(message) {
    console.log(message);
  }
}

// C
{
  f(message) {
    console.log(message);
  }
}

A is valid today, B and C are possible with the syntax in this proposal. The "look-a-like" problem is subjective, so maybe not a concern? I just wanted to make a record—feel free to close if this is considered "not an issue"

rwaldron avatar Nov 09 '17 18:11 rwaldron

Good call - the block/object literal similarity seems like an issue there.

ljharb avatar Nov 09 '17 18:11 ljharb

Apologies for the silly question, but just to see if I understand this correctly:

  • A is an object with a property f that is a function
  • B is a labelled block with a function call f(message, function() { ... })
  • C is a non-labelled block with the same function call

Is the confusion between A and B in that it is hard to tell the difference between the two?

samuelgoto avatar Nov 10 '17 00:11 samuelgoto

I think it's hard to tell the difference between all of A, B, and C - especially B and C.

ljharb avatar Nov 10 '17 09:11 ljharb