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

Feature request: shorthand syntax for field access #1171

Open
dasch opened this issue Sep 3, 2024 · 0 comments
Open

Feature request: shorthand syntax for field access #1171

dasch opened this issue Sep 3, 2024 · 0 comments

Comments

@dasch
Copy link

dasch commented Sep 3, 2024

Languages such as Elm have special syntax that simplifies expressions such as function(x) x.y into just .y; adding support for this shorthand would improve the legibility of Jsonnet code by removing repetitive boilerplate, e.g. this code:

std.map(function(city) city.name, std.map(function(country) country.capital, countries))

could instead be written as

std.map(.name, std.map(.capital, countries))

A function that takes a single argument and just looks at a field on it is very common, e.g.

std.filter(.isPublic, files)
std.flatMap(.members, groups)
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