声明性语言的实现细节固有必要 [英] Are the implementation details of declarative languages inherently imperative
问题描述
我在想什么是基本运算符&所实现的功能是由命令式操作符&
欢呼
AWC
如果我正确理解你的问题,我不认为这是一条硬性规定。例如,你可以使用像Lisp这样的函数式语言来为自己创建一个解释器。在这种情况下,实现细节以功能方式实现(因为Lisp是一种功能性语言)。
另外,如果您的语言是Turing Complete,那么您可以用它来实现任何其他语言的解析器/解释器/编译器。有必要的图灵完全语言和函数/声明性图灵完全语言。但是所有代码最终都是通过汇编或机器代码完成的,这本质上是必不可少的。理论上,我上面所说的是真实的,但显然不是在实践中:)。
作为一个有趣的历史,LISP是一个完全理论化的结构;这是计算机语言的数学符号。它仍然是理论的,直到LISP的 eval
函数在IBM 704上由Steve Russel在机器代码中实现:
根据Paul Graham在Hackers&画家,页。 185,麦卡锡说:史蒂夫罗素说,看看,为什么我不编程这个评估...,我对他说,嘿,嘿,理论与实践混淆,这个 eval是为了阅读,而不是为了计算,但他继续做下去,也就是说,他将我的论文中的eval编译成IBM 704机器码,修正了bug,然后将它标榜为Lisp解释器,当然是这样的,所以Lisp本质上就是今天的形式......(强调我的)
所以一旦再次,理论与实践之间的微妙之处。 :)I'm reading 'Functional Programming' by Tomas Petricek & Jon Skeet and I understand the difference between declarative & imperative programming.
What I was wondering is how are the primitive operators & functions implemented, are declarative languages constructed from imperative operators & functions.
Cheers
AWC
If I understand your question correctly, I don't think that is a hard and fast rule. For example, you can use a functional language like Lisp, to create an interpreter for itself. In this case, the implementation details are implemented in a functional manner (because Lisp is a functional language).
Also, if you have a language that is Turing Complete, you can use it to implement a parser/interpreter/compiler for any other language. There are imperative Turing-Complete languages, and functional/declarative Turing-Complete languages.
But all code eventually comes done to assembly or machine code, which is inherently imperative. In theory, what I said above is true, but apparently not in practice :).
As an interesting historical aside, LISP was a completely theoretical construct; it was a mathematical notation for computer languages. It remained theoretical until LISP's eval
function was implemented in machine code by Steve Russel on an IBM 704:
According to what reported by Paul Graham in Hackers & Painters, p. 185, McCarthy said: "Steve Russell said, look, why don't I program this eval..., and I said to him, ho, ho, you're confusing theory with practice, this eval is intended for reading, not for computing. But he went ahead and did it. That is, he compiled the eval in my paper into IBM 704 machine code, fixing bug , and then advertised this as a Lisp interpreter, which it certainly was. So at that point Lisp had essentially the form that it has today..." (emphasis mine)
So once again, the subtleties between theory and practice. :)
这篇关于声明性语言的实现细节固有必要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!