M. Henz, Thomas Tan, Zachary Chua, P. Jung, Yee-Jian Tan, Xinyi Zhang, Jingjing Zhao
{"title":"A stepper for a functional JavaScript sublanguage","authors":"M. Henz, Thomas Tan, Zachary Chua, P. Jung, Yee-Jian Tan, Xinyi Zhang, Jingjing Zhao","doi":"10.1145/3484272.3484968","DOIUrl":null,"url":null,"abstract":"The first two chapters of the introductory computer science textbook Structure and Interpretation of Computer Programs, JavaScript Adaptation (SICP JS), use a subset of JavaScript called Source §2. The book introduces the reduction-based “substitution model” as a first mental model for the evaluation of Source §2 programs. To support the learner in adopting this mental model, we built an algebraic stepper—a tool for visualizing the evaluation of Source §2 programs according to the model. As a sublanguage of JavaScript, Source §2 differs from other purely functional programming languages by using a statement-oriented syntax, with statement sequences, return statements, and block-scoped declarations. For the purpose of this tool description, we distill these distinguishing features—along with explicit recursion—into a Source §2 sublanguage that we call Source §0, and focus on a stepper for this language. We formalize the substitution model of Source §0 as a lambda-calculus-style reduction semantics that handles explicit recursion by term graph rewriting and faithfully implements the JavaScript specification, when restricted to that language. Our implementation of the stepper represents term graphs by persistent data structures that maximize sharing and enable random access to all steps. This work presents the first reduction-based semantics for a JavaScript sublanguage and the first algebraic stepper for a language with return statements and block-scoped declarations. The tool supports the learner with step-level explanations, redex highlighting, and function-level skipping and can also be used for teaching the applicative-order-reduction lambda calculus.","PeriodicalId":159099,"journal":{"name":"Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E","volume":"235 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2021-10-17","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"4","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the 2021 ACM SIGPLAN International Symposium on SPLASH-E","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1145/3484272.3484968","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 4
Abstract
The first two chapters of the introductory computer science textbook Structure and Interpretation of Computer Programs, JavaScript Adaptation (SICP JS), use a subset of JavaScript called Source §2. The book introduces the reduction-based “substitution model” as a first mental model for the evaluation of Source §2 programs. To support the learner in adopting this mental model, we built an algebraic stepper—a tool for visualizing the evaluation of Source §2 programs according to the model. As a sublanguage of JavaScript, Source §2 differs from other purely functional programming languages by using a statement-oriented syntax, with statement sequences, return statements, and block-scoped declarations. For the purpose of this tool description, we distill these distinguishing features—along with explicit recursion—into a Source §2 sublanguage that we call Source §0, and focus on a stepper for this language. We formalize the substitution model of Source §0 as a lambda-calculus-style reduction semantics that handles explicit recursion by term graph rewriting and faithfully implements the JavaScript specification, when restricted to that language. Our implementation of the stepper represents term graphs by persistent data structures that maximize sharing and enable random access to all steps. This work presents the first reduction-based semantics for a JavaScript sublanguage and the first algebraic stepper for a language with return statements and block-scoped declarations. The tool supports the learner with step-level explanations, redex highlighting, and function-level skipping and can also be used for teaching the applicative-order-reduction lambda calculus.
计算机科学入门教材《计算机程序的结构与解释》(Structure and Interpretation of computer Programs, SICP JS)的前两章使用了JavaScript的一个子集Source§2。本书介绍了基于简化的“替代模型”作为评估源§2程序的第一个心智模型。为了支持学习者采用这种心理模型,我们建立了一个代数步进-一个根据模型可视化Source§2程序评估的工具。作为JavaScript的一个子语言,Source§2不同于其他纯函数式编程语言,它使用了面向语句的语法,包括语句序列、返回语句和块作用域声明。出于本工具描述的目的,我们将这些显著的特征——连同显式递归——提取到Source§2子语言中,我们称之为Source§0,并将重点放在该语言的步进上。我们将Source§0的替换模型形式化为lambda-calculus-style约简语义,该语义通过项图重写处理显式递归,并忠实地实现JavaScript规范,当受该语言限制时。我们的步进实现通过持久的数据结构来表示术语图,这些数据结构可以最大限度地共享并允许对所有步进进行随机访问。这项工作为JavaScript子语言提供了第一个基于约简的语义,并为具有返回语句和块作用域声明的语言提供了第一个代数步进。该工具支持学习者的步骤级解释,索引突出显示和函数级跳过,也可以用于教学应用序约λ演算。