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.
翻译:在类型和连带效应系统中,环境因模拟实际使用方式的连带效应而更加丰富,通常通过单一变量的说明。连带效应是自下而上计算,通过固定的一组代数操作员将每个术语的子术语的连带效应结合起来。我们表明,可以采用这种原则性办法追踪在必要模式中的共享,即执行过程中可能引入的变量之间的联系。这提供了非结构性连带效应的重要例子,这种非结构连带效应无法以可变方式计算,因为使用某一变量的方式可以影响其他变量的连带效应。为了说明这种方法的有效性,我们加强了类型跟踪系统共享,以模拟一套与独特性和不可变性有关的复杂特征。由于基于共效的方法,我们可以以简单的方式表达这些特征,并以标准技术证明相关属性。