[Enhancement] Proposal for new language feature for the short hand property #1275
Labels
enhancement
New feature or request
help wanted
Extra attention is needed
lang-design
Issues or PRs related to kcl language design and KEPs
Feature Request
Is your feature request related to a problem? Please describe:
When I'm working I like convenience and flexibility, and that's why I love KCL! I have an idea that I think will push that frontier a bit further.
Describe the feature you'd like:
Javascript is a pretty horrible language, but there is one cool feature that came out in ES6 - object property shorthand!
In short, when creating objects, we can use shorthand notation to assign variables as object properties with the same name.
In KCL, there could be shorthand assignment too, not only by variable name, but by type as well! Examples:
Describe alternatives you've considered:
N/A, I just thought this feature was really cool
Teachability, Documentation, Adoption, Migration Strategy:
As a bonus if that would work outside schemas and instances, that would be so convenient. Currently, I'm working on IaC tool and if I define e.g. one provider (like terraform provider) in a file, why should I add identifier to unique resource (I know it probably have very logical reason, but like I said, I like flexibility 😃)? But, when I need to add second instance, another shorthand instance cannot be added and I must use identifier.
Example:
That's all from me, let me know what you think!
The text was updated successfully, but these errors were encountered: