zoukankan      html  css  js  c++  java
  • Compiler 1.6.5 —1.6.7

    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.

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

     

     

     

     

  • 相关阅读:
    [Linux]常用命令之【tar/zip/unzip/gzip/gunzip】
    [Git]解决: error: unable to create file src/main/webapp/xxxxxx/xxxx: Filename too long
    [Git]解决:error: The following untracked working tree files would be removed by checkout:
    [Linux]命令行分类
    [数据库/MYSQL]#解决缺陷#设置Unique索引时:"[Err] 1071
    [Java EE]辨析: POJO(PO / DTO / VO) | BO/DO | DAO
    [Java]遍历枚举类型为List
    【Vue】在Vue项目中调试Vue源码——修改Vue项目引入的vue文件
    【Vue】Vue源码解读之Component组件注册
    【Vue】驼峰命名法和短横线命名法的转换以及Vue源码中对驼峰式和大写式查找的支持
  • 原文地址:https://www.cnblogs.com/ljlkfx/p/4476274.html
Copyright © 2011-2022 走看看