Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax overlap with proposal-shorthand-improvements #13

Open
rbuckton opened this issue Jun 1, 2020 · 0 comments
Open

Syntax overlap with proposal-shorthand-improvements #13

rbuckton opened this issue Jun 1, 2020 · 0 comments

Comments

@rbuckton
Copy link

rbuckton commented Jun 1, 2020

I presented on https://github.com/rbuckton/proposal-shorthand-improvements several years ago and while it did not advance to Stage 1, I intend to bring it back to committee in the near future with some amendments. My concern is that there is significant syntactic overlap between the two proposals which could be confusing should both be adopted:

this proposal:

const state2 = #{
  ...state1,
  counters[0].value: 2, // sets `state2.counters[0].value` to `2`
  metadata.lastUpdate: 1584383011300, // sets `state2.metadata.lastUpdate` to `1584383011300`
};

proposal-shorthand-improvements:

const counters = [{ value: 2 }];
const metadata = { lastUpdate: 1584383011300 };
const state2 = {
  ...state1,
  counters[0].value, // sets `state2.value` to `counters[0].value`
  metadata.lastUpdate // sets state2.lastUpdate` to `metadata.lastUpdate`
}

The proposal was not adopted due to some syntactic concerns that I intend to address, however the proposal has been on the backburner while I focused on advancing other proposals. Also note that my proposal is based on existing prior art in C#:

var x = new { y = 1 };
var obj = new { x.y };
Console.WriteLine(obj.y); // 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant