当前位置: 首页 > news >正文

GNU make manual 翻译( 一百五十八)

继续翻译

   The previous example shows two levels of nesting, but any number of
levels 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 name
are 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 and
function 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 would
ever want to write a nested reference as convoluted as this one, but it
works: `$($($(z)))' expands to `$($(y))' which becomes `$($(subst
1,2,$(x)))'.  This gets the value `variable1' from `x' and changes it
by 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'。

后文待续

转载于:https://www.cnblogs.com/gaojian/archive/2012/10/04/2710962.html

相关文章:

  • Linux自学笔记——nginx详解
  • POJ 1722 DP
  • centos搭建ssh
  • Direct2D入门
  • Mina2.0框架源码剖析(二)
  • 64位ubuntu下安装32位jdk
  • response.setHeader()的用法
  • PCIE BAR空间
  • HDU5115:Dire Wolf——题解+翻译
  • JS常用代码
  • [iOS]中字体样式设置 API
  • 20个Jquery表单插件
  • MAC上Git安装与GitHub基本使用
  • ORACLE -- RAC Debug 之路 CRS-0184错误与CRS初始化
  • chrome插件控制台
  • CEF与代理
  • echarts花样作死的坑
  • js算法-归并排序(merge_sort)
  • Laravel5.4 Queues队列学习
  • mac修复ab及siege安装
  • PHP 使用 Swoole - TaskWorker 实现异步操作 Mysql
  • Vue全家桶实现一个Web App
  • 如何优雅地使用 Sublime Text
  • 使用Envoy 作Sidecar Proxy的微服务模式-4.Prometheus的指标收集
  • 用quicker-worker.js轻松跑一个大数据遍历
  • No resource identifier found for attribute,RxJava之zip操作符
  • 1.Ext JS 建立web开发工程
  • FaaS 的简单实践
  • python最赚钱的4个方向,你最心动的是哪个?
  • ​Linux Ubuntu环境下使用docker构建spark运行环境(超级详细)
  • # 20155222 2016-2017-2 《Java程序设计》第5周学习总结
  • #Z2294. 打印树的直径
  • (1/2) 为了理解 UWP 的启动流程,我从零开始创建了一个 UWP 程序
  • (175)FPGA门控时钟技术
  • (23)Linux的软硬连接
  • (Redis使用系列) Springboot 实现Redis消息的订阅与分布 四
  • (二)构建dubbo分布式平台-平台功能导图
  • (六)c52学习之旅-独立按键
  • (万字长文)Spring的核心知识尽揽其中
  • (五)IO流之ByteArrayInput/OutputStream
  • (译) 理解 Elixir 中的宏 Macro, 第四部分:深入化
  • (原创)boost.property_tree解析xml的帮助类以及中文解析问题的解决
  • .net core 控制台应用程序读取配置文件app.config
  • .net 调用php,php 调用.net com组件 --
  • .net操作Excel出错解决
  • .sh 的运行
  • @基于大模型的旅游路线推荐方案
  • [ C++ ] template 模板进阶 (特化,分离编译)
  • [ HTML + CSS + Javascript ] 复盘尝试制作 2048 小游戏时遇到的问题
  • [Android View] 可绘制形状 (Shape Xml)
  • [BZOJ1040][P2607][ZJOI2008]骑士[树形DP+基环树]
  • [BZOJ4010]菜肴制作
  • [C++]AVL树怎么转
  • [EMWIN]FRAMEWIN 与 WINDOW 的使用注意
  • [HTML]Web前端开发技术12(HTML5、CSS3、JavaScript )——喵喵画网页