google / google/go-jsonnet

folding syntax

Open
#382 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
1.8k
Forks
263
PR merge metrics
No merged PRs in 30d

Description

I'd like to propose a folding syntax for single valued objects, loosely inspired by CUE: https://cuelang.org/docs/tutorials/tour/intro/fold/

It's frequently the case that when I want to override a specific property of something nested very deeply, I need to write a lot of encapsulated curly braces, which wastes a lot of lines and screen space.
The other option of folding these and having something like `}}}}}}}` doesn't look much better either, and is error prone.

Instead, we could allow this:
```jsonnet
{
abc+: def+: xyz+: {
foo: "bar"
}
}
```

which would desugar into this:

```jsonnet
{
abc+: {
def+: {
xyz+: {
foo: "bar"
}
}
}
}
```

I think this would make several scenarios much more concise. WDYT @sbarzowski @sparkprime?

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.