arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2411.16571cs.PL
收藏

Pantograph:一个流畅且带类型的结构编辑器

Pantograph: A Fluid and Typed Structure Editor

Jacob Prinz, Henry Blanchette, Leonidas Lampropoulos

AI总结:

本文提出 Pantograph 结构编辑器,通过单孔上下文的剪切粘贴和类型差异范畴,在始终维持程序良构与良类型的同时保持编辑流畅性,并通过教学实验验证其优于传统文本编辑器。

摘要:

结构编辑器直接在程序的语法树结构上操作。乍一看,这带来了令人兴奋的可能性:这种编辑器可以强制实现正确性属性——程序可以通过构造而成为良构的,有时甚至是良类型的。不幸的是,试图严格强制这些属性的传统结构编辑方法面临一个看似根本性的问题,文献中称之为“粘滞性”。对现有程序进行修改通常需要暂时破坏程序结构——但不允许这种修改又会使程序难以编辑!在本文中,我们提出了一种结构编辑方案,它始终维持有效的程序结构,同时不牺牲自由编辑程序所必需的流畅性。两个关键部分帮助解决了这一难题:首先,我们为树状结构开发了一种新颖的选择推广,它恰当地推广了基于文本的选择和编辑,使用户能够通过剪切和粘贴单孔上下文来自由重排代码片段;其次,我们用类型差异范畴为这些单孔上下文赋予类型,并探索了为系统性地维持良类型性而产生的系统的元理论。我们将我们的方法实现为一个名为 Pantograph 的编辑器,并进行了一项研究,在研究中我们成功地教会了学生使用 Pantograph 编程,并将他们的表现与传统文本编辑器进行了比较。

英文摘要:

Structure editors operate directly on a program's syntactic tree structure. At first glance, this allows for the exciting possibility that such an editor could enforce correctness properties: programs could be well-formed and sometimes even well-typed by construction. Unfortunately, traditional approaches to structure editing that attempt to rigidly enforce these properties face a seemingly fundamental problem, known in the literature as viscosity. Making changes to existing programs often requires temporarily breaking program structure -- but disallowing such changes makes it difficult to edit programs! In this paper, we present a scheme for structure editing which always maintains a valid program structure without sacrificing the fluidity necessary to freely edit programs. Two key pieces help solve this puzzle: first, we develop a novel generalization of selection for tree-based structures that properly generalizes text-based selection and editing, allowing users to freely rearrange pieces of code by cutting and pasting one-hole contexts; second, we type these one-hole contexts with a category of type diffs and explore the metatheory of the system that arises for maintaining well-typedness systematically. We implement our approach as an editor called Pantograph, and we conduct a study in which we successfully taught students to program with Pantograph and compare their performance against a traditional text editor.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑