一句话:通过用 Racket 实现 Lindenmayer 系统 DSL,展示 Racket 作为快速构建领域特定语言的抽象平台的能力。
本文是一篇函数式珍珠(functional pearl),围绕如何构建“终极抽象”的抽象平台展开。作者以理论植物学中的计算模型 Lindenmayer 系统(L-system)为案例,在 Racket 中逐步实现一个用于描述与生成 L-system 的领域特定语言(DSL)。文章并不侧重形式化定义或性能评测,而是通过可读的实现走查,展示 Racket 的语言构造能力如何让 DSL 的定义、扩展与嵌入变得直接而灵活。其核心论点是:正如 DSL 是终极抽象,Racket 可作为“抽象之抽象”的平台,帮助语言设计者快速构建新的 DSL。该珍珠以教程式叙述说明此设计理念,并为类似 DSL 实现提供示例。
Domain-specific languages are the ultimate abstraction, dixit Paul Hudak. But what abstraction should we use to build such ultimate abstractions? What is sauce for the goose is sauce for the gander: a language, of course! Racket is the ultimate abstraction-abstraction, a platform for quickly and easily building new ultimate abstractions. This pearl demonstrates Racket's power by taking a leisurely walk through the implementation of a DSL for Lindenmayer systems, the computational model par excellence of theoretical botany.
@article{St-AmourFFYF17,
title = {Herbarium Racketensis: a stroll through the woods (functional pearl)},
author = {Vincent St-Amour and Daniel Feltey and Spencer P. Florence and Shu-Hung You and Robert Bruce Findler},
journal = {Proceedings of the ACM on Programming Languages},
volume = {1},
number = {ICFP},
year = {2017},
doi = {10.1145/3110245}
}