Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

cue: back-quoted identifier literals #2

Closed
mpvl opened this issue Jan 30, 2019 · 2 comments
Closed

cue: back-quoted identifier literals #2

mpvl opened this issue Jan 30, 2019 · 2 comments
Labels
FeatureRequest New feature or request

Comments

@mpvl
Copy link
Contributor

mpvl commented Jan 30, 2019

There is currently no way to reference a top-level field with a non-standard character:

"foo-bar": "can't touch this"

a: // cannot reference "foo-bar"

One solution is to introduce $ to refer to the root object. This is possible, but such references often result in poor configuration file design. It is also one other thing to learn for a user.

An alternative approach is to allow a syntax for identifiers with non-standard characters. Swift and GCL allow back quotes for this purpose:

"foo-bar": "can touch this"

a: `foo-bar`

Main drawback: now we have three ways of referring to identifiers. Allowing back quotes also on the left hand side might mitigate this issue. The string approach may be considered a relic of JSON and hardly used unless needed for interpolation.

`foo-bar`: "can touch this"

a: `foo-bar`

"dynamic\(interpolated)": 42

cue fmt could be used to canonicalize LHS identifiers according to this rule.

@mpvl mpvl added the FeatureRequest New feature or request label Jan 30, 2019
@mpvl mpvl changed the title Consider implementing back-quoted identifier literals cue: consider implementing back-quoted identifier literals Jan 30, 2019
@mpvl mpvl changed the title cue: consider implementing back-quoted identifier literals cue: back-quoted identifier literals Jan 30, 2019
@mpvl
Copy link
Contributor Author

mpvl commented Oct 25, 2019

The new aliases provide a better alternative. Closing.

@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#2.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants