使用部分求值的fexample的实际编译:在纯函数式Lisp中,fexample可以高性能地替换宏
Practical compilation of fexprs using partial evaluation: Fexprs can performantly replace macros in purely-functional Lisp
摘要:
宏是Lisp语言的一个常见部分,也是它们最受称赞的特性之一。许多研究都致力于使宏更安全,更强大,从而在多个领域取得了进展,包括维护卫生和类型化程序阶段。然而,宏确实有各种缺点,包括二等的。特别是对于急切的函数式编程来说,它们无法传递给高阶函数或自由组合。由John Shutt重新制定的Fexample提供了一个一流的、更强大的宏替代方案,可以很好地与纯函数式编程相结合。不幸的是,fexample的朴素执行比宏慢得多,这是由于在运行时重新执行未优化的操作合并器代码,在基于宏的语言中,这些代码将在编译时被扩展然后优化。为了表明fexample可以实际替代宏,我们制定了一个小的纯功能fexpr基于Lisp,Kraken,与在线部分评估和编译框架,支持一流的,部分静态数据环境,可以完全优化远离fexample,使用和编写的风格的宏。我们展示了我们的部分评估和编译框架产生的代码比简单的解释快70,000倍以上,因为消除了重复的工作和静态信息的暴露,从而实现了额外的优化。此外,我们的Kraken编译器的性能优于现有的支持fexpr的解释型语言,包括在一个基准测试中将NewLisp的fexpr性能提高了233倍。
英文摘要:
Macros are a common part of Lisp languages, and one of their most lauded features. Much research has gone into making macros both safer and more powerful resulting in developments in multiple areas, including maintaining hygiene, and typed program staging. However, macros do suffer from various downsides, including being second-class. Particularly egregious for eager functional programming, they are unable to be passed to higher-order functions or freely composed. Fexprs, as reformulated by John Shutt, provide a first-class and more powerful alternative to macros that meshes well with pure functional programming. Unfortunately, naive execution of fexprs is much slower than macros due to re-executing unoptimized operative combiner code at runtime that, in a macro-based language, would have been expanded and then optimized at compile time. To show that fexprs can be practical replacements for macros, we formulate a small purely functional fexpr based Lisp, Kraken, with an online partial evaluation and compilation framework that supports first-class, partially-static-data environments and can completely optimize away fexprs that are used and written in the style of macros. We show our partial evaluation and compilation framework produces code that is more than 70,000 times faster than naive interpretation due to the elimination of repeated work and exposure of static information enabling additional optimization. In addition, our Kraken compiler performs better compared to existing interpreted languages that support fexprs, including improving on NewLisp's fexpr performance by 233x on one benchmark.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。