blob: ef96dcf6fe86510f529fea3e522e40674d35b61c [file] [log] [blame] [view]
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01001[TOC](Readme.md) [Prev](selectors.md) [Next](emit.md)
2
Marcel van Lohuizenaf0932f2019-01-11 13:03:56 +01003_References and Visibility_
4
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +01005# Aliases
6
7An alias defines a local macro.
8
9A typical use case is to provide access to a shadowed field.
10
Jonathan Amsterdamabeffa42019-01-20 10:29:29 -050011Alias are not members of a struct. They can be referred to only within the
12struct, and they do not appear in the output.
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010013
14<!-- CUE editor -->
15```
Jonathan Amsterdame4790382019-01-20 10:29:29 -050016A = a // A is an alias for a
Marcel van Lohuizen75cb0032019-01-11 12:10:48 +010017a: {
18 d: 3
19}
20b: {
21 a: {
22 // A provides access to the outer "a" which would
23 // otherwise be hidden by the inner one.
24 c: A.d
25 }
26}
27```
28
29<!-- result -->
30```
31a: {
32 d: 3
33}
34b: {
35 a: {
36 c: 3
37 }
38}
39```