Imperative session types provide an imperative interface to session-typed communication. In such an interface, channel references are first-class objects with operations that change the typestate of the channel. Compared to functional session type APIs, the program structure is simpler at the surface, but typestate is required to model the current state of communication throughout. Following an early work that explored the imperative approach, a significant body of work on session types has neglected the imperative approach and opts for a functional approach that uses linear types to manage channel references soundly. We demonstrate that the functional approach subsumes the early work on imperative session types by exhibiting a typing and semantics preserving translation into a system of linear functional session types. We further show that the untyped backwards translation from the functional to the imperative calculus is semantics preserving. We restrict the type system of the functional calculus such that the backwards translation becomes type preserving. Thus, we precisely capture the difference in expressiveness of the two calculi and conclude that the lack of expressiveness in the imperative calculus is largely due to restrictions imposed by its type system.
翻译:强制会话类型为会话类型通信提供了必需的界面。 在这样的界面中, 频道引用是一流对象, 操作会话类型会改变频道类型。 与功能会话类型 API 相比, 程序结构表面比较简单, 但需要类型来模拟当前通信状态 。 在早期研究紧急方法后, 大量关于会话类型的工作忽视了紧急方法, 选择了使用线性类型正确管理频道引用的功能性方法 。 我们证明, 功能方法通过显示一个打字和语义来将紧急会话类型的早期工作归为线性函数会话类型系统, 将早期工作归为优先会话类型 。 我们进一步显示, 从功能到必用计算方式的不打印后翻译是保留语义。 我们限制功能性计算系统的类型系统类型, 使后向翻译成为类型保存。 因此, 我们精确地捕捉到两种计算方法的表达性差异, 我们的结论是, 关键计算方法缺乏明确性在很大程度上是由于其类型系统施加的限制 。