A model for reasoning about JavaScript promises

A model for reasoning about JavaScript promises
复制标题

JavaScript Promise 的推理模型

DOI:
10.1145/3133910
复制
发表时间:
2017
影响因子:
--
通讯作者:
Tip, Frank
Tip, Frank
中科院分区:
--
文献类型:
--
作者:
Madsen, Magnus;Lhoták, Ondřej;Tip, Frank

文献摘要

参考文献

被引文献

相似文献

在JavaScript程序中,在基于Web的用户界面、通过HTTP请求与服务器通信以及非阻塞I/O等情况下会出现阻塞。基于事件的编程是最流行的管理事件的方法,但是存在诸如丢失事件和事件竞争之类的问题,并且导致代码难以理解和调试。最近,ECMAScript 6增加了对promise的支持,这是一种管理错误的替代机制,使程序员能够在支持正确错误处理的同时链接异步计算。然而,promise本身就很复杂且容易出错,因此程序员可以从基于promise的代码正确性推理技术中获益。由于ECMAScript 6规范是非正式的,并且是为JavaScript引擎的实现者设计的,因此它并没有为正式推理提供合适的基础。本文介绍了λp,这是一个核心演算,它抓住了ECMAScript 6 promise的本质。基于λp,我们引入了Promise图,这是一种程序表示,可以帮助程序员调试基于Promise的代码。然后,我们报告的案例研究中,我们调查如何的承诺图可以帮助调试相关的代码片段中的承诺发布到StackOverflow网站的错误。
In JavaScript programs, asynchrony arises in situations such as web-based user-interfaces, communicating with servers through HTTP requests, and non-blocking I/O. Event-based programming is the most popular approach for managing asynchrony, but suffers from problems such as lost events and event races, and results in code that is hard to understand and debug. Recently, ECMAScript 6 has added support for promises, an alternative mechanism for managing asynchrony that enables programmers to chain asynchronous computations while supporting proper error handling. However, promises are complex and error-prone in their own right, so programmers would benefit from techniques that can reason about the correctness of promise-based code.Since the ECMAScript 6 specification is informal and intended for implementers of JavaScript engines, it does not provide a suitable basis for formal reasoning. This paper presents λp, a core calculus that captures the essence of ECMAScript 6 promises. Based on λp, we introduce the promise graph, a program representation that can assist programmers with debugging of promise-based code. We then report on a case study in which we investigate how the promise graph can be helpful for debugging errors related to promises in code fragments posted to the StackOverflow website.
future 的语义及其在程序优化中的应用
DOI: --
发表时间: 1995
期刊: ACM-SIGACT Symposium on Principles of Programming Languages
影响因子: --
作者:
C. Flanagan;M. Felleisen
通讯作者: M. Felleisen
DOI: 10.1007/978-3-642-54807-9_12
发表时间: 2014-04
期刊: --
影响因子: --
作者:
Magnus Madsen;Esben Andreasen
通讯作者: Magnus Madsen;Esben Andreasen
DOI: --
发表时间: 2008
期刊: Asian Symposium on Programming Languages and Systems
影响因子: --
作者:
S. Maffeis;John C. Mitchell;Ankur Taly
通讯作者: Ankur Taly
使用 PLT Redex 进行语义工程
DOI: --
发表时间: 2009
期刊:
影响因子: --
作者:
M. Felleisen;R. Findler;M. Flatt
通讯作者: M. Flatt
jQuery 静态分析的确定性
DOI: --
发表时间: 2014
期刊: Conference on Object-Oriented Programming Systems, Languages, and Applications
影响因子: --
作者:
Esben Andreasen;Anders Møller
通讯作者: Anders Møller