APL 可以作为 DSL 在 Scala 中实现吗?
有一种古老的计算机语言,称为 APL。这可以在 Scala 中作为 DSL 实现吗?
There is a old computer language called APL. Could this be implemented in Scala as a DSL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有人可能会给出比这更好的答案,但这是我最初的想法:
出于多种原因,Scala DSL 无法完全复制 APL 语法,其中之一就是
'单引号'
可以在 APL 中表示字符串,但在 Scala 中则不能。另外(来自 wikipedia 页面)
也不是有效的 Scala。
我不知道你能接近多远,但......
Someone could probably give a better answer than this, but this is my initial thought:
A Scala DSL should in theory be able to implement any programming language because it could build up an arbitrary structure representing the syntax, and then evaluate that.
A Scala DSL could not exactly replicate APL syntax for many reasons, one of which is that
'single quotes'
can denote a string in APL, but not in Scala. Also (from the wikipedia page)
wouldn't be valid Scala.
I don't know how close you could get, though...
Javascript 实现位于:https://github.com/ngn/apl
A Javascript implementation exists here: https://github.com/ngn/apl