google / google/jsonnet

Feature request: shorthand syntax for field access

Open
#1,171 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

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:

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

could instead be written as

```jsonnet
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.

```jsonnet
std.filter(.isPublic, files)
std.flatMap(.members, groups)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.