为什么要使用面向堆栈的语言? [英] Why use a stack-oriented language?

查看:177
本文介绍了为什么要使用面向堆栈的语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近查看了 Factor ,使用基于堆栈概念的语言的想法非常有趣. (这是我第一次使用面向堆栈的语言.)但是,我没有看到这种范例的任何实际优势.对我来说,这似乎比它的价值还大.为什么我要使用诸如Factor或Forth之类的面向堆栈的语言?

I recently took a look at Factor, and the idea of having a language based around the concept of a stack is very interesting. (This was my first encounter with a stack-oriented language.) However, I don't see any practical advantages of such a paradigm. To me, it just seems like more trouble than it's worth. Why would I use a stack-oriented language such as Factor or Forth?

我忽略了因素(例如双关语),例如工具和库的可用性.我只问语言范式本身.

推荐答案

堆栈方向是一个实现细节.例如,Joy可以使用重写实现-无堆栈.这就是为什么有些人倾向于说连接的"或构成的"的原因.使用引号和组合器,您可以编写代码而无需考虑堆栈.

Stack orientation is an implementation detail. For example, Joy can be implemented using rewriting - no stack. This is why some prefer to say "concatenative" or "compositional". With quotations and combinators you can code without thinking about the stack.

用纯净的成分表达自己,没有局部语言或命名参数是关键.它非常简洁,没有语法开销.组合使排除冗余和代数"操作代码变得非常容易.将其煮沸至其本质.

Expressing yourself with pure composition and without locals or named arguments is the key. It's extremely succinct with no syntactic overhead. Composition makes it very easy to factor out redundancy and to "algebraically" manipulate your code; boiling it down to its essence.

一旦您爱上了这种无点式样式,即使使用其他语言中的最细微的组合语法(即使只是一个点),您也会对它感到恼火.在连接语言中,空格是合成运算符.

Once you've fallen in love with this point-free style you'll become annoyed by even the slightest composition syntax in other languages (even if just a dot). In concatenative languages, white space is the composition operator.

这篇关于为什么要使用面向堆栈的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆