Compiler  1.6.5 —1.6.7

Dynamic Scope

Technically, any scoping policy is dynamic if it is based on factor(s) that can be known only when the program executes.

如果作用域策略只有在程序执行时才知道,那么该作用域策略就是动态的。

A  use of a name x refers to

the declaration of x in the most recently called procedure with such a declaration.

一个x的使用指的是最近被调用得车工序用了这样一个声明的x的声明。

我们考虑两种动态策略的例子:

c预处理的宏扩展和面向对象的方法解析。

declarations and definitions

The apparently similar terms "declaration" and "definition" for program ming-language concepts are actually quite different. Declarations tell us about the types of things, while definitions tell us about their values . Thus, int i is a declaration of i, while i = 1 is a definition of i.

int i is a declaration of i ,while i =1 is a definition of i .S

In fact, in order to interpret x, we must use the usual dynamic-scope rule. We examine all the function calls that are currently active, and we take the most recently called function that has a declaration of x. It is to this declaration that the use of x refers.

为了解释x,我们必须用动态范围规则。 我们检测所有那些现在已经激活的韩硕地套用。我们选声明x的最近的函数调用。

Dynamic scope resolution is also essential for polymorphic procedures ,those that have two or more definitions  for the same name ,depending only on the types of the arguments .

Analogy Between Static and Dynamic Scoping

In a sense, the dynamic rule is to time as the static rule is to space. While the static rule asks us to find the declaration whose unit (block) most closely surrounds the physical location of the use, the dynamic rule asks us to find the declaration whose unit (procedure invocation) most closely surrounds the time of the use.

1.6.6 parameter passing mechanisms

参数传递机制

In this section, we shall consider

how the actual parameters (the parameters used in the call of a procedure) are associated with the formal parameters (those used in the procedure definition ).

The great majority of languages use either "call-by-value," or "call-by-reference," or both. We shall explain these terms, and another method known as "call-by-name," that is primarily of historical interest.

最主要的事值调用和引用调用。历史上还有名字调用。

Call-by-value has the effect that all computation involving the

formal parameters done by the called procedure is local to that procedure, and the actual parameters themselves cannot be changed.

However,that in c we can pass a pointer to a variable to allow that variable to be changed by the collee.

然而在c中可以传递一个指针给一个变量以此来允许变量被调用者改变。

因此值传递可以通过指针来改变实际变量。

Call-by-reference

In call-by-reference, the address of the actual parameter is passed to the cailee as the value of the corresponding formal parameter.

在引用调用中,实际参数的地址传递给了被调用着 对应的形式参数。

Uses of the formal parameter in the code of the callee are implemented by following this pointer to the location indicated by the caller.

在被调用处,使用形式参数是实际参数的地址。

Changes to the formal parameter thus appear as changes to the actual parameter.

1.6.7 Aliasing 别名

It is possible that two formal parameters can refer to the same location;

两个参数可能指向同一个地址。

such variables are said to be aliases of one another. As a result, any two variables, which may appear to take their values from two distinct formal parameters, can become aliases of each other, as well.

如果任意两个变量,可能获取数据来源于两个不同的参数,可能是相互之间的别名。

最新文章

  1. Golang 编写的图片压缩程序,质量、尺寸压缩,批量、单张压缩
  2. 15.django之Django-Rest-Framework
  3. C++ STL之vector用法总结
  4. IOS 手势-轻点、触摸、手势、事件
  5. stm32 USART rs485 rs232
  6. Best Cow Fences_二分&&DP
  7. Java EXCEL导入的两种方式JXL和POI
  8. PNG兼容IE6解决方法
  9. js如何实现一定时间后去执行一个函数
  10. arrayList里的快速失败
  11. PTA题---求两个有序序列中位数所体现的思想。
  12. 在ARC下,assign和weak的区别
  13. Bootstrap3 栅格系统-栅格参数
  14. 图示Java类的初始化顺序
  15. 解决Windows下mysql无法启动1067错误
  16. day 7-21 pymysql模块
  17. jdbc问题:Access denied for user ''@'localhost''是因为没输入账户和密码
  18. Navicat连接mysql备份数据库提示:1577 – Cannot proceed because system tables used by Event Scheduler where found damaged at server start
  19. 堆排序获取TopN
  20. lvs 最常用算法 + tcpdump vrrp 抓包

热门文章

  1. Django创建数据表
  2. A Simple Example About Privileged Methods in JavaScript
  3. Android大牛的博客
  4. The input stream is not a valid binary format.
  5. TP5.x——开启跨域访问
  6. Visual C++ 2010入门教程
  7. RMQ(Range Minimum Query)问题(转)
  8. codeforces 689E E. Mike and Geometry Problem(组合数学)
  9. Groupby 方法语法
  10. 使用jQuery的tab控件