REPL,解释器和编译器之间的关系 [英] Relation between REPL, interpreter and compiler

查看:305
本文介绍了REPL,解释器和编译器之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

维基百科


REPL通常被错误命名为
解释器。这是一个误称 - 许多
编程语言使用
编译(包括字节码
编译)有REPL,例如
Common Lisp和Python。


来自回复此帖


互动译员使用REPL。
解释器不需要有
一个。你可以在非交互模式(文件)
上运行Python,例如
,它不会使用read-eval-print
循环。


我想知道是否REPL [del]总是存在[/ del] 仅存在用于解释器?维基百科说REPL也存在一个编译器?如果是,那怎么样?



感谢和问候!



通过翻译,

解决方案

我不知道你是要求常用的字词还是别的。 p>

在任何情况下,REPL是一个读取评估打印循环(见第一个字母)。
如果你有一个解释器不读取你的程序或不评价它(即理解你想要它做什么和做它)或不打印结果在任何地方,什么好?



如果你看不到任何东西,它不会听到你不会做你想要的反正或你只有1尝试,你可以



也许可能会有一些滑稽的单词反对,例如如果它只是改变一个显示的图标,是真的打印吗?这样:-)
或者如果它不是从键盘读取,是真的读吗?
真正的哲学,真的。



真正的是,一些系统反应不同,取决于你是从键盘还是从文件读取。我不知道这是什么使用,但我想你可以提供帮助给人类(即命令完成等),当他实际上在键盘上打字。



也许有些不从文件读取时接受多于1个表达式?


我想知道REPL是否总是存在一个解释器?


我猜这是一个解释器定义的问题。如果你认为它意味着(在实际意义上)某事做我要告诉它做的事,没有。


维基百科说REPL是否也适用于编译器?如果是,那怎么样?


当然是的。所有LISP系统都是这样。
他们感觉就像一个解释器,但是随着时间的推移,系统学习如何对自己进行短语,学习什么改变,什么不改变,只是编译不改变机器代码。



现在Java也是这样,你的VM会话持续的时间越长,它会发现如何使事情更快,如果你停止更改事情,它最终将运行整个程序在机器代码中。



解释器/编译器的整个人工区别是偶然的,也就是说,因为资源限制在当天。 p>

From Wikipedia:

The REPL is commonly misnamed an interpreter. This is a misnomer—many programming languages that use compilation (including bytecode compilation) have REPLs, such as Common Lisp and Python.

From a reply to this post

Interactive interpreters use REPLs. An interpreter is not required to have one. You can run Python, for example, in non-interactive mode (on a file) and it will not use a read-eval-print loop.

I was wondering if REPL [del] always exists [/del] exists only for an interpreter? Does Wikipedia say REPL also exists for a compiler? If yes, how is that like?

Thanks and regards!

By interpreter, I mean the one perform execution immediately after compilation.

解决方案

I'm not sure whether you are asking for the words commonly used or something else.

In any case, a REPL is a Read Eval Print Loop (see first letters). If you have an interpreter that doesn't read your program or doesn't evaluate it (i.e. "understand" what you want it to do and do it) or doesn't print the results anywhere, what good is it?

If you wouldn't see anything at all and it wouldn't hear you it wouldn't do what you want anyway or you only had 1 try you could as well put a rock on the table instead of the computer.

Maybe there could be funny playing-with-words objections like "if it only changes an icon that is displayed, is it really printing?" and such :-) Or "if it isn't reading from the keyboard, is it really reading?". Silly pure philosophy, really.

What's true is that some systems react differently depending on whether you make them read from the keyboard or from a file. I'm not sure what the use of that is, but I guess you could offer help to the human (i.e. command completion etc) when he's actually typing on the keyboard.

Maybe some don't accept more than 1 expression when reading from a file?

I was wondering if REPL always exists for an interpreter?

I guess its a question of the definition of "interpreter". If you take it to mean (in the pragmatic sense) "something that does what I tell it to do", no. How would you tell it if it won't listen?

Does Wikipedia say REPL also exists for a compiler? If yes, how is that like?

Yes, of course. All LISP systems are like that. They feel exactly like an interpreter but stuff just gets magically faster over time as the system learns how you phrase yourself and learns what changes and what doesn't and just compiles what doesn't change to machine code.

Java also does that nowadays, the longer your VM session lasts the more it finds out how to make things faster and if you stop changing things it will eventually end up running the entire program in machine code.

The whole artificial distinction of interpreter/compiler came to be accidentially, that is to say, because of resource constraints back in the day.

这篇关于REPL,解释器和编译器之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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