论文标题
共享和突变的系数
Coeffects for Sharing and Mutation
论文作者
论文摘要
在类型和访问系统中,通过模拟它们实际使用的系数,通常通过单个变量的注释来丰富上下文。系数是根据固定的代数运算符组结合的,在每个术语中,将其在每个项中的构图组合。我们表明,可以采用这种原则性的方法来跟踪在命令范式中的共享,即执行可能引入的变量之间的链接。这提供了一个非结构系数的重要示例,该系数无法通过可变性计算,因为使用给定变量的方式会影响其他变量的系数。为了说明该方法的有效性,我们增强了类型系统跟踪共享,以建模一组与唯一性和不变性相关的复杂功能。得益于基于系数的方法,我们可以简单地表达此类功能,并证明与标准技术相关的属性。
In type-and-coeffect systems, contexts are enriched by coeffects modeling how they are actually used, typically through annotations on single variables. Coeffects are computed bottom-up, combining, for each term, the coeffects of its subterms, through a fixed set of algebraic operators. We show that this principled approach can be adopted to track sharing in the imperative paradigm, that is, links among variables possibly introduced by the execution. This provides a significant example of non-structural coeffects, which cannot be computed by-variable, since the way a given variable is used can affect the coeffects of other variables. To illustrate the effectiveness of the approach, we enhance the type system tracking sharing to model a sophisticated set of features related to uniqueness and immutability. Thanks to the coeffect-based approach, we can express such features in a simple way and prove related properties with standard techniques.