v0.0.10
Language touch ups
New-style Comprehensions
This release is characterized by the redesign of field comprehensions, now struct comprehensions. The old format is still supported, but cue fmt will rewrite it to the new format.
The new format looks like:
for k, v in a {
"\(k)": v
}instead of
"\(k)": v for k, v in aThis may seem like a gratuitous change, but it has many advantages:
- generated structs are syntactically and semantically like embeddings
- large comprehensions are clearer
- a single iteration can add multiple fields
- makes scoping clearer
Removal of block quotes
Because a comprehension may start with if, we can use if false { ... } to disable a large block. This, and various other considerations have led to the decision to remove block quotes from the language.
Block quotes are still supported, but they are no longer generated and cue fmt will translate them.
Quoted identifiers
CUE now allows identifiers to be quoted with back ticks:
`foo-bar`: 2
baz: `foo-bar`This allows fields with odd names to still be referenced using identifiers. More importantly, the allowed space of identifiers should ideally be limited. For instance, it is a good idea to require them to be in Unicode normal form NFC. Allowing arbitrary strings as identifiers seemed like a bad idea. CUE will soon disallow this. For now, cue fmt rewrites strings used labels is they are referenced by some nodes.
Quotes also have another benefit. A disadvantage of the new style comprehensions is that it is harder and less clear to allow the keywords of comprehensions as field names. Consider for instance:
for x in src: 2CUE will now only allow one such keyword as a field name, but requires quoting otherwise. A future cue fmt may rewrite this as:
`for` x `in` src: 2Backwards incompatible changes
The language changes introduced do not break anything, as the old formats are still supported. However, at some point they won’t be. So be sure to run cue fmt at some point.
- The
ast.LabelNamehas been changed to have proper semantics in light of the upcoming changes. The signature has been change to reflect the changes properly and to assure code is properly investigated in light of these changes. - Comprehensions now iterate only over non-optional regular fields, as would perhaps be expected.
- Top-level emit values are printed in eval output
- Top-level struct embeddings are merged in the API
All changes
27 changesby area
cue21
cue/ast/astutilexport Resolve functionalitycue/ast/astutilimplement Applycue/ast/astutilpick name based on import pathcue/ast/astutilsupport adding importscue/ast/astutiluse unlikely name for importcue/astadd API for setting a positioncue/astadd API to modify commentscue/astadd back LabelNamecue/astconvenience constructors for common typescue/astfirst step to new comprehension format.cue/formatexpressions.inputcue/formatoutput new comprehension formatcue/formattweaks to support embeddingscue/parserparse new comprehension syntaxcueadd test for package name overridecuefor structs, iterate only on non-optional regular fieldscueimplement quoted identifierscueimplementation of new comprehensionscueremove block comments and slices from the languagecuetighten API of comprehensionscuevarious cleanup
doc3
doc/refallow embeding to be Expressiondoc/tutorial/basicssome minor fixesdoc/tutorial/basicsupdate w.r.t. spec.
Other3
cmd/cuemake fmt rewrite deprecated cuepkg/listadd Haskell-style Take and Droppkg/listadding slice function
Downloads
Every file this release published on GitHub, with its SHA-256. Most people install CUE as Installing CUE describes, which also shows how to check a download.
Archives
| Platform | File and SHA-256 |
|---|---|
| macOS, Intel | cue_c19949649f378c0fc079e7407fd98138820c065e11ef6318f84bad084126ab4d |
| Linux, Arm64 | cue_0e0d5a53d7db2a3a5689ccf9edb0502c745a55fe89d025b2e945bc8b5783d5ab |
| Linux, x86-64 | cue_af10c541f500bce2187d37c23379c63ee02a1470888292b0e779b36f6d75a300 |
| Windows, x86-64 | cue_6073a8cf6671e301a067064275d59fc79dd87264639a7658063f3cee5445487a |
SHA-256 checksums for all of these: checksums.txt