Skip to content

Explore CUE postfix aliases experiment for generated code #111

@myitcv

Description

@myitcv

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:

  1. Identify specific patterns in the generated CUE that would benefit.
  2. Evaluate readability improvements for real chart output.
  3. Provide feedback on the proposal from a code generator's perspective.

Additional context

Upstream discussion: cue-lang/cue#4014

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions