什么是Metacircular国米preTER的确切定义是什么? [英] What is the exact definition of a Metacircular Interpreter?

查看:335
本文介绍了什么是Metacircular国米preTER的确切定义是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是合法的调用用C或一个PHP间$ P $用PHP编写的metacircular PTER C编译器?是该定义仅适用于特定类型的语言有效的,象Lisp?总之,什么是一个跨preTER应满足被称为Metacircular?条件

Is it legal to call a C compiler written in C or a PHP interpreter written in PHP metacircular? Is this definition valid only for languages of a specific type, like Lisp? In short, what are the conditions that an interpreter should satisfy for being called Metacircular?

推荐答案

一个metacircular间preTER是写在一个(可能是更基本的)实现相同语言的跨preTER。这通常是与增加新功能,语言,或创建一个不同的方言进行试验。

A metacircular interpreter is an interpreter written in a (possibly more basic) implementation of the same language. This is usually done to experiment with adding new features to a language, or creating a different dialect.

此过程与Lisp语言相关的原因是因为高清晰的纸国米preTER的艺术,它显示了基于几个方案之间metacircular preters。 (本文是书SICP内核,其第四章致力于通过别人创造例如懒洋洋地评估计划)

The reason this process is associated with Lisp is because of the highly lucid paper "The Art of the Interpreter", which shows several metacircular interpreters based on Scheme. (The paper is the kernel for the book SICP, and its fourth chapter works through others that create e.g. a lazily-evaluated Scheme.)

这也是的极大地的更容易在一个homoiconic语言(语言的code可以被操纵在运行时的数据),如Lisp的,Prolog的,和等等。做

This is also vastly easier to do in a "homoiconic" language (a language whose code can be manipulated as data at runtime), such as Lisp, Prolog, and Forth.

至于你直接的问题 - C编译器不会是一个跨preTER可言。写在自己的语言编译器是自托管,这是一个类似的属性,但更相关的引导。在PHP一个PHP间preTER可能不会算,因为你可能会被重新执行的过程中语言的非平凡量。传统metacircular间preTER的主要好处是的这样做是没有必要的 - 你可以在现有的解析器,垃圾收集(如有)等堵塞,并且只写一个顶层评估与不同的语义。在计划或Prolog的,它往往比code的页面更少。

As to your direct question - the C compiler wouldn't be an interpreter at all. A compiler written in its own language is 'self-hosting', which is a similar property, but more related to bootstrapping. A PHP interpreter in PHP probably wouldn't count, since you would likely be re-implementing a nontrivial amount of the language in the process. The major benefit of a conventional metacircular interpreter is that doing so isn't necessary - you can plug in the existing parser, garbage collection (if any), etc., and just write a top-level evaluator with different semantics. In Scheme or Prolog, it's often less than a page of code.

这篇关于什么是Metacircular国米preTER的确切定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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