继续翻译
The previous example shows two levels of nesting, but any number oflevels is possible. For example, here are three levels: x = y y = z z = u a := $($($(x)))Here the innermost `$(x)' expands to `y', so `$($(x))' expands to`$(y)' which in turn expands to `z'; now we have `$(z)', which becomes`u'. References to recursively-expanded variables within a variable nameare reexpanded in the usual fashion. For example: x = $(y) y = z z = Hello a := $($(x))defines `a' as `Hello': `$($(x))' becomes `$($(y))' which becomes`$(z)' which becomes `Hello'. Nested variable references can also contain modified references andfunction invocations (*note Functions for Transforming Text:Functions.), just like any other reference. For example, using the`subst' function (*note Functions for String Substitution and Analysis:Text Functions.): x = variable1 variable2 := Hello y = $(subst 1,2,$(x)) z = y a := $($($(z)))eventually defines `a' as `Hello'. It is doubtful that anyone wouldever want to write a nested reference as convoluted as this one, but itworks: `$($($(z)))' expands to `$($(y))' which becomes `$($(subst1,2,$(x)))'. This gets the value `variable1' from `x' and changes itby substitution to `variable2', so that the entire string becomes`$(variable2)', a simple variable reference whose value is `Hello'.
前面的例子展示了两层的嵌套,但是任何层的嵌套都是可能的。例如,这里有三个层次:
x = y
y = z z = u a := $($($(x)))这里,最里层的 `$(x)' 扩展到 `y',于是 `$($(x))' 扩展到`$(y)',进而扩展到`z'; 现在我们拥有`$(z)',它将变为 `u'。
在一个变量里面,对递归式扩展的变量的参照会合正常的扩展一样。例如:
x = $(y)
y = z z = Hello a := $($(x))定义 `a' 为 `Hello': `$($(x))' 为 `$($(y))' ,然后转化为,`$(z)' ,再转化为 `Hello'。
嵌套的变量参照也能包含变化的参照和函数激活(*note Functiosn for Transforming Text: Functions),就像其他的参照一样。例如,使用 subst函数(*Functions for String Substitution and Analysis: Text Functions.):
x = variable1
variable2 := Hello y = $(subst 1,2,$(x)) z = y a := $($($(z)))最终定义 `a' 为 `Hello'。是否会有人写出这样的嵌套式的参照是令人怀疑的,但是它确实可以工作:
`$($($(z)))' 扩展为 `$($(y))' ,它变成 `$($(subst
1,2,$(x)))'. 然后从x 来获得 `variable1' ,再通过变换,把它变成 `variable2', 这样整个字符串就变成了`$(variable2)', 成为一个简单的变量参照,其值为 `Hello'。后文待续