Replies: 7 comments 12 replies
-
Overall this design seems simpler and more consistent. This proposal provides a syntax for labeling keys, and eliminates labeling values altogether, with this functionality substituted by the
To be fair this scenario probably doesn't occur very often.
I like |
Beta Was this translation helpful? Give feedback.
-
One suggestion that came up is that with the
In practice, the difference between |
Beta Was this translation helpful? Give feedback.
-
How would this new syntax interact with interpolating values into the built-in function The following (unpublished!) update to a cuelang.org guide is being held back from being published both because we consider it to be a bit confusing, but also because its aliasing seems to lead to a contradiction (tracked in #4038). How would it be represented using the new alias syntax?
|
Beta Was this translation helpful? Give feedback.
-
Line 144 of the proposal uses |
Beta Was this translation helpful? Give feedback.
-
I might well be missing something here, but do the proposed scope semantics of |
Beta Was this translation helpful? Give feedback.
-
FYI - the proposal contains an unfinished sentence "To bind with" |
Beta Was this translation helpful? Give feedback.
-
Another modification: scoping rules refinement:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
📋 Proposal Details:
Proposal: Postfix Aliases
Postfix Aliases Proposal Summary
This proposal introduces a new syntax for aliases in CUE that addresses several issues with the current system. The main problem is that CUE currently uses the
=
symbol for aliases across seven different kinds in five syntactic positions, creating unnecessary complexity. This conflicts with how=
is used for assignment in other languages (Dhall, Nickel, PKL, KCL) and even within CUE itself forlet
statements. Additionally, the current syntax encourages field aliases when value aliases would be more appropriate in most cases.The proposed solution replaces all current alias forms with a single postfix notation using the
~
symbol. Instead ofF=label: value
, the new syntax would belabel~X: value
. To access different aspects of an alias, three new builtins are introduced:keyOf(X)
for the field name,refOf(X)
for the field reference (similar to current field aliases), andvalueOf(X)
for the field's value. UsingX
directly is shorthand forvalueOf(X)
. The proposal also introduces aself
keyword to refer to the current scope, addressing a previous limitation where the package root couldn't be referenced.The benefits of this change are significant. The syntax becomes more regular and consistent, with aliases appearing in only one position instead of three. The
~
symbol avoids the confusion with assignment semantics and integrates better with potential future features like dot notation (a~A.b~B: {...}
) and query syntax. This is particularly valuable for complex comprehensions where aliases can be bound within query paths, making the code more readable. For example:members.*~M.children.*~C.address~A
clearly shows the path traversal with bound aliases at each level.The transition strategy involves using
cue fmt
andcue fix
to automatically rewrite existing code, with both syntaxes supported during a transition period. This allows the CUE team to introduce the new syntax before making final decisions about repurposing the freed=
symbol for other features. The proposal carefully considers alternatives and edge cases, such as list element aliases, while maintaining backward compatibility through the module version system.[Summary generated by Claude AI]
Full Proposal
The complete proposal with all technical details, examples, and implementation notes can be found in the proposal document.
How to Comment
Please provide feedback on this proposal:
Last updated: 2025-08-05 15:30:40 UTC
Beta Was this translation helpful? Give feedback.
All reactions