一句话:提出基于操作的框架与 delta 语言 DM,将开发者对输出的直接操作自动融合进函数式源代码,实现代码不敏感的直接操作。
双向实时编程(BLP)系统允许开发者通过直接操纵程序输出来修改程序,使更新后的程序能产生所操纵的输出。现有基于操作的方法通常为每种直接操作硬编码程序修改,难以扩展;且为将操纵反映到源码,系统需追踪修改输出到相应代码片段并做代码变换,这要求用户了解源码及其变化,“直接”操纵因此变得间接。本文提出一种新的基于操作的双向实时编程框架,可自动将直接操作融合进源码,从而支持代码不敏感的直接操作。首先设计简单而富有表达力的 delta 语言 DM,用于表达对输出值的常见直接操作;然后给出融合算法,将直接操作传播进函数式源程序,并尽可能将其应用于常量,否则将操作嵌入程序的“恰当位置”。作者证明了融合算法的正确性,即更新后的程序执行可得到被操纵的输出。为展示 DM 的表达力与融合算法的有效性,实现了原型 SVG 编辑器 FuseDM,支持基于 GUI 的直接操作,并从空白代码出发成功设计了 14 个基准示例。
Bidirectional live programming systems (BLP) enable developers to modify a program by directly manipulating the program output, so that the updated program can produce the manipulated output. One state-of-the-art approach to BLP systems is operation-based, which captures the developer's intention of program modifications by taking how the developer manipulates the output into account. The program modifications are usually hard coded for each direct manipulation in these BLP systems, which are difficult to extend. Moreover, to reflect the manipulations to the source program, these BLP systems trace the modified output to appropriate code fragments and perform corresponding code transformations. Accordingly, they require direct manipulation users be aware of the source code and how it is changed, making “direct” manipulation (on output) be “indirect”. In this paper, we resolve this problem by presenting a novel operation-based framework for bidirectional live programming, which can automatically fuse direct manipulations into the source code, thus supporting code-insensitive direct manipulations. Firstly, we design a simple but expressive delta language DM capable of expressing common direct manipulations for output values. Secondly, we present a fusion algorithm that propagates direct manipulations into the source functional programs and applies them to the constants whenever possible; otherwise, the algorithm embeds manipulations into the “proper positions” of programs. We prove the correctness of the fusion algorithm that the updated program executes to get the manipulated output. To demonstrate the expressiveness of DM and the effectiveness of our fusion algorithm, we have implemented FuseDM, a prototype SVG editor that supports GUI-based operations for direct manipulation, and successfully designed 14 benchmark examples starting from blank code using FuseDM.
@article{paperbot2614,
title = {Fusing Direct Manipulations into Functional Programs},
author = {Xing Zhang and Ruifeng Xie and Guanchen Guo and Xiao He and Tao Zan and Zhenjiang Hu},
journal = {Proceedings of the ACM on Programming Languages},
volume = {8},
number = {POPL},
year = {2024},
doi = {10.1145/3632883}
}