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.


翻译:宏是Lisp语言的常见组成部分,也是最受赞誉的特性之一。大量研究致力于使宏更安全、更强大,催生了多个领域的进展,包括保持卫生性以及类型化程序阶段划分。然而,宏存在各种缺点,包括作为二等公民。对于急切函数式编程而言尤为严重的是,宏无法传递给高阶函数或自由组合。John Shutt重新定义的fexpr提供了一等化且更强大的宏替代方案,与纯函数式编程完美契合。不幸的是,fexpr的朴素执行速度远慢于宏,因为在基于宏的语言中,原本可在编译时展开并优化的操作符组合子代码,在运行时需重新执行未经优化的代码。为证明fexpr可实用替代宏,我们基于fexpr构建了小型纯函数式Lisp语言Kraken,其在线部分求值与编译框架支持一等化的部分静态数据环境,并能完全优化掉以宏风格使用和编写的fexpr。实验表明,由于消除了重复计算并暴露静态信息以实现额外优化,我们的部分求值与编译框架生成的代码比朴素解释执行快超过70,000倍。此外,与支持fexpr的现有解释型语言相比,Kraken编译器的性能更优,包括在某一基准测试中将NewLisp的fexpr性能提升233倍。

0
下载
关闭预览

相关内容

高阶和符号计算是一本国际期刊,它提供了一个广谱论坛,讨论高阶和符号设施编程的结果和思想:一级函数和延续、效果和高阶类型、对象、参与者和数据程序。内容包括从理论和设计到实践和经验的论文,尤其是实践中使用的理论。该杂志促进具有广泛兴趣和专业知识的研究人员之间的思想交流和协同作用。覆盖范围包括带效果的函数编程;面向对象编程;并行、并发、分布式和移动符号和函数计算;编程概念和抽象-数据抽象、延迟计算、无限数据对象、自引用、反射、连续、组件、通用函数,继承、封装、保护、持久性、元对象、通信协议等等。官网链接:https://link.springer.com/journal/10990
专知会员服务
161+阅读 · 2021年3月6日
专知会员服务
102+阅读 · 2020年12月19日
Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
164+阅读 · 2019年10月12日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
【哈佛大学商学院课程Fall 2019】机器学习可解释性
专知会员服务
106+阅读 · 2019年10月9日
微软全力拥抱 Java !
CSDN
0+阅读 · 2022年9月7日
VCIP 2022 Call for Demos
CCF多媒体专委会
1+阅读 · 2022年6月6日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
深度自进化聚类:Deep Self-Evolution Clustering
我爱读PAMI
15+阅读 · 2019年4月13日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
笔记 | Sentiment Analysis
黑龙江大学自然语言处理实验室
10+阅读 · 2018年5月6日
Reinforcement Learning: An Introduction 2018第二版 500页
CreateAMind
14+阅读 · 2018年4月27日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Arxiv
0+阅读 · 2023年5月10日
VIP会员
最新内容
战力倍增器:自主武器系统与乌克兰及加沙冲突
人工智能赋能战场情报:提速决策进程
专知会员服务
2+阅读 · 7月17日
《拥抱新兴技术:面向未来军官的教育革新》
专知会员服务
6+阅读 · 7月17日
《无人地面战车(UGV)的崛起》报告
专知会员服务
8+阅读 · 7月16日
相关VIP内容
专知会员服务
161+阅读 · 2021年3月6日
专知会员服务
102+阅读 · 2020年12月19日
Keras François Chollet 《Deep Learning with Python 》, 386页pdf
专知会员服务
164+阅读 · 2019年10月12日
机器学习入门的经验与建议
专知会员服务
94+阅读 · 2019年10月10日
【哈佛大学商学院课程Fall 2019】机器学习可解释性
专知会员服务
106+阅读 · 2019年10月9日
相关资讯
微软全力拥抱 Java !
CSDN
0+阅读 · 2022年9月7日
VCIP 2022 Call for Demos
CCF多媒体专委会
1+阅读 · 2022年6月6日
Hierarchically Structured Meta-learning
CreateAMind
27+阅读 · 2019年5月22日
深度自进化聚类:Deep Self-Evolution Clustering
我爱读PAMI
15+阅读 · 2019年4月13日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
笔记 | Sentiment Analysis
黑龙江大学自然语言处理实验室
10+阅读 · 2018年5月6日
Reinforcement Learning: An Introduction 2018第二版 500页
CreateAMind
14+阅读 · 2018年4月27日
相关基金
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
1+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Top
微信扫码咨询专知VIP会员