Is your feature request related to a problem? Please describe.
helm2cue generates CUE that sometimes needs to refer to the current scope or bind names during traversal. For example, range comprehensions produce for k, v in #values.x { ... } patterns, and helper call sites use struct unification (_helper & {#arg: expr}).out to pass context. The current generated code is functional but can be verbose, especially in nested traversals.
Describe the solution you'd like
CUE's proposed postfix aliases experiment (cue-lang/cue#4014) introduces a unified ~ syntax for aliases, a self keyword for referring to the current scope, and keyOf/refOf/valueOf builtins. This could improve the generated CUE in several ways:
- The
self keyword could simplify patterns where the generated code needs to reference the enclosing struct value.
- Postfix aliases in comprehensions (
members.*~M.children.*~C) could make nested range patterns more readable.
keyOf/refOf/valueOf could simplify dynamic key patterns that currently use string interpolation or index expressions.
Explore this experiment to:
- Identify specific patterns in the generated CUE that would benefit.
- Evaluate readability improvements for real chart output.
- Provide feedback on the proposal from a code generator's perspective.
Additional context
Upstream discussion: cue-lang/cue#4014
Is your feature request related to a problem? Please describe.
helm2cue generates CUE that sometimes needs to refer to the current scope or bind names during traversal. For example, range comprehensions produce
for k, v in #values.x { ... }patterns, and helper call sites use struct unification(_helper & {#arg: expr}).outto pass context. The current generated code is functional but can be verbose, especially in nested traversals.Describe the solution you'd like
CUE's proposed postfix aliases experiment (cue-lang/cue#4014) introduces a unified
~syntax for aliases, aselfkeyword for referring to the current scope, andkeyOf/refOf/valueOfbuiltins. This could improve the generated CUE in several ways:selfkeyword could simplify patterns where the generated code needs to reference the enclosing struct value.members.*~M.children.*~C) could make nested range patterns more readable.keyOf/refOf/valueOfcould simplify dynamic key patterns that currently use string interpolation or index expressions.Explore this experiment to:
Additional context
Upstream discussion: cue-lang/cue#4014