Type systems usually characterize the shape of values but not their free variables. However, many desirable safety properties could be guaranteed if one knew the free variables captured by values. We describe CCsubBox, a calculus where such captured variables are succinctly represented in types, and show it can be used to safely implement effects and effect polymorphism via scoped capabilities. We discuss how the decision to track captured variables guides key aspects of the calculus, and show that CCsubBox admits simple and intuitive types for common data structures and their typical usage patterns. We demonstrate how these ideas can be used to guide the implementation of capture checking in a practical programming language.
翻译:类型系统通常以价值的形状为特征,但不是自由变量的形状。然而,许多可取的安全属性都可以得到保证,只要人们知道通过价值所捕捉的自由变量。我们描述了CCsubBox,这是一个计算器,这种计算器所捕捉的变量在类型上以简洁的形式表示,并表明它能够用来通过范围能力安全地实施效果并产生多重形态。我们讨论了跟踪所捕捉的变量的决定如何指导微积分的关键方面,并表明CCsubBox为共同数据结构及其典型使用模式接纳了简单和直观的类型。我们展示了这些想法如何用实用的编程语言指导捕捉检查的实施。