v0.0.10

cue-lang/cue Released

A release of CUE OSS · its page on GitHub

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 a

This 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: 2

CUE 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: 2

Backwards 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.LabelName has 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 functionality21fa535
  • cue/ast/astutilimplement Apply0dcf17b
  • cue/ast/astutilpick name based on import pathe4523e2
  • cue/ast/astutilsupport adding imports530467a
  • cue/ast/astutiluse unlikely name for import24d14c5
  • cue/astadd API for setting a position40c76b7
  • cue/astadd API to modify commentsf0bcfb9
  • cue/astadd back LabelName92408e3
  • cue/astconvenience constructors for common types749a667
  • cue/astfirst step to new comprehension format.fe5f886
  • cue/formatexpressions.input57d6751
  • cue/formatoutput new comprehension format9af9a90
  • cue/formattweaks to support embeddings982b194
  • cue/parserparse new comprehension syntax71eafc4
  • cueadd test for package name override3c38bfc
  • cuefor structs, iterate only on non-optional regular fields4245fb4
  • cueimplement quoted identifiers835ed58
  • cueimplementation of new comprehensionsda00c8b
  • cueremove block comments and slices from the language7fc421b
  • cuetighten API of comprehensions1fa0552
  • cuevarious cleanupb36d81a

doc3

  • doc/refallow embeding to be Expression1f5a903
  • doc/tutorial/basicssome minor fixesd44b092
  • doc/tutorial/basicsupdate w.r.t. spec.48f82f1

Other3

  • cmd/cuemake fmt rewrite deprecated cueb50aecd
  • pkg/listadd Haskell-style Take and Drop15aeace
  • pkg/listadding slice function1ffb95f

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

PlatformFile and SHA-256
macOS, Intelcue_0.0.10_Darwin_x86_64.tar.gzc19949649f378c0fc079e7407fd98138820c065e11ef6318f84bad084126ab4d
Linux, Arm64cue_0.0.10_Linux_arm64.tar.gz0e0d5a53d7db2a3a5689ccf9edb0502c745a55fe89d025b2e945bc8b5783d5ab
Linux, x86-64cue_0.0.10_Linux_x86_64.tar.gzaf10c541f500bce2187d37c23379c63ee02a1470888292b0e779b36f6d75a300
Windows, x86-64cue_0.0.10_Windows_x86_64.zip6073a8cf6671e301a067064275d59fc79dd87264639a7658063f3cee5445487a

SHA-256 checksums for all of these: checksums.txt

Install CUE