变异与别名的句法模型
A Syntactic Model of Mutation and Aliasing
摘要:
传统上,命令式语言的语义模型使用模仿记忆的辅助结构。这样,所有权和其他封装属性需要从这种全局内存的图形结构中重建。我们提出了一种替代的“语法”模型,内存被编码为程序的一部分,而不是作为一个单独的资源。这意味着执行可以通过重写源代码术语来建模,就像在函数式程序的语义模型中一样。从形式上讲,这是通过块构造来实现的,它引入了局部变量声明,当它们的初始化表达式被求值时,局部变量声明扮演着内存的角色。通过这种方式,我们获得了一种语言语义,它直接表示在句法层面上的约束别名,允许更简单的推理有关的属性。为了说明这一优势,我们考虑的问题,在文献中广泛研究,表征一个孤立的部分的内存,这是无法达到通过外部参考。在语法模型中,封闭的块值,称为“胶囊”,提供了一个简单的表示内存的孤立部分,胶囊可以安全地移动到内存中的另一个位置,而不引入共享,通过“仿射”变量。我们证明,语法模型可以编码在传统的,因此有效地实现。
英文摘要:
Traditionally, semantic models of imperative languages use an auxiliary structure which mimics memory. In this way, ownership and other encapsulation properties need to be reconstructed from the graph structure of such global memory. We present an alternative "syntactic" model where memory is encoded as part of the program rather than as a separate resource. This means that execution can be modelled by just rewriting source code terms, as in semantic models for functional programs. Formally, this is achieved by the block construct, introducing local variable declarations, which play the role of memory when their initializing expressions have been evaluated. In this way, we obtain a language semantics which directly represents at the syntactic level constraints on aliasing, allowing simpler reasoning about related properties. To illustrate this advantage, we consider the issue, widely studied in the literature, of characterizing an isolated portion of memory, which cannot be reached through external references. In the syntactic model, closed block values, called "capsules", provide a simple representation of isolated portions of memory, and capsules can be safely moved to another location in the memory, without introducing sharing, by means of "affine' variables. We prove that the syntactic model can be encoded in the conventional one, hence efficiently implemented.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。