21 April 2005
This post may be outdated due to it was written on 2005. The links may be broken. The code may be not working anymore. Leave comments if needed.

原文位于 http://www.parrotcode.org/glossary.html


Short descriptions of words you might need to know that show up in Parrot development.

一些在 Parrot 开发中出现的您应该要知道的词的简短描述.



Think of continuations as an execution "context". This context includes everything local to that execution path, not just the stack. It is a snapshot in time (minus global variables). While it is similar to C's setjmp (taking the continuation)/longjmp (invoking the continuation), longjmp'ing only works "down" the stack; jumping "up" the stack (ie, back to a frame that has returned) is bad. Continuations can work either way.

您可以将 continuations 当成一个可以执行的“上下文”。此上下文包括所有局部的东西到那个可执行路径,而不仅仅是堆栈。它是那个时间的一个快照(减去全局变量)。它有点类似 C 语言中的 setjmp(捕获 continuation)/longjmp(调用 continuation)。longjmp只作用于向下的堆栈与jumping只作用于向上的(像后退到一个返回的框架),这很糟糕。而 continuation 能作用于任一情况。

We can do two important things with continuations:

我们可以用 continuations 做两件重要的事:

1. Create and pass a continuation object to a subroutine, which may recursively pass that object up the call chain until, at some point, the continuation can be called/executed to handle the final computation or return value. This is pretty much tail recursion.

创建和传递一个 continuation 对象到一个子程序,此子程序可以递归传递此对象到调用链,直到在某一点,continuation 被调用/运行去处理最后的计算或返回值。这几乎是尾部递归。

2. Continuations can be taken at an arbitrary call depth, freezing the call chain (context) at that point in time. If we save that continuation object into a variable, we can later reinstate the complete context by its "handle". This allows neat things like backtracking that aren't easily done in conventional stacked languages, such as C. Since continuations represent "branches" in context, it requires an environment that uses some combination of heap-based stacks, stack trees and/or stack copying.

Continuations 能用于任一调用深度,在某点及时地冻结一个调用链(上下文)。如果你保存了此 continuation 对象到一个变量,那么我们可以通过它的句柄来恢复全部的上下文。这就提供了了某些灵巧的东西如回溯,这在传统的堆栈语言中(如 C )并不容易做到。因为 continuations 类似于上下文的“分支”,它要求一个由堆积的堆栈/heap-based stacks,堆栈树和(或)堆栈复制品联合而成的环境。

It is common in a system that supports continuations to implement co-routines on top of them.

在那些支持 continuations 的系统顶部执行 co-routines 是很寻常的。

A continuation is a sort of super-closure. When you take a continuation, it makes a note of the current call stack and lexical scratchpads, along with the current location in the code. When you invoke a continuation, the system drops what it's doing, puts the call stack and scratchpads back, and jumps to the execution point you were at when the continuation was taken. It is, in effect, like you never left that point in your code.

一个 continuation 是一种高级闭包/super-closure。当你捕获一个 continuation 时,它便记录了当前的调用堆栈和 lexical scratchpads,连同代码的当前位置。当你调用一个 continuation 时,系统便撤消您正在所做的,将调用堆栈和scratchpads(中间结果暂存器)退回来,并跳回你捕获 continuation 时的那个执行点。它实际上非常像你从来没有离开过代码中的那个点。

Note that, like with closures, it only puts the scratchpads back in scope - it doesn't do anything with the values in the variables that are in those scratchpads.

注意:类似闭包,它只将作用域里的 scratchpads 退回来 - 它不对那些在 scratchpads 中变量的值做任何改变。


Co-routines are virtually identical to normal subroutines, except while subroutines always execute from their starting instruction to where they return, co-routines may suspend themselves (or be suspended asynchronously if the language permits) and resume at that point later. We can implement things like "factories" with co-routines. If the co-routine never returns, every time we call it, we "resume" the routine.

Co-routines 事实上与一般的子程序没啥区别,除了子程序总是从他们的开始指令一直运行到返回值,而 co-routines 可以悬挂(推迟)自己(或者如果语言允许可以不同时的(异步)被悬挂)和在稍候从那一点继续执行。我们可以用 co-routines 来实现一个类似“工厂”的东西,只要它没有返回值,每次您调用它,我们就继续执行“生产流程”。

A co-routine is a subroutine that can stop in the middle, and start back up later at the point you stopped. For example:

co-routine 是一个可以在中途停止和在稍候在那停止的点上继续运行的子程序。例如:

sub sample : coroutine {
   print "A\n";
   print "B\n";

print "Foo!\n";

will print



Basically, the yield keyword says, "Stop here, but the next time we're called, pick up at the next statement." If you return from a co-routine, the next invocation starts back at the beginning. Co-routines remember all their state, local variables, and suchlike things.

主要是, 关键词 yield 像是在说, “在这停下,但我们下次叫您的时候,在下一语句继续前进”;假设当一个 co-routine 有返回值,那下次的调用会从程序的头部开始。Co-routines 能记住它所有的 state,本地变量,和类似的东西。


COW stands for Copy On Write. This is a pure speed-hack technique that copies strings without actually copying the string data until it's absolutely necessary.

COW 是 Copy On Write 的缩写。这是一个纯粹 加速/speed-hack 技术,它复制字符串但实际上没有复制它的数据,只到它真正有用的时候才复制。

If you have a string A, and make a copy of it to get string B, the two strings should be identical, at least to start. With COW, they are, because string A and string B aren't actually two separate strings - they're the same string, marked COW. If either string A or string B are changed, the system notes it and only at that point does it make a copy of the string and change it.

假设您有一个字符串A,而且将它复制到B,至少在开始,这两个字符串应当是一样的。而用了 COW ,字符串A和B实际上就不是分离的字符串,它们是被 COW 打上标记为相同的字符串。如果字符串A或B改变了,系统会记录下来,而且只在需要的那个点时才对字符串做拷贝并改变它。

If the program never actually changes the string - something that's fairly common - the program need never make a copy, saving both memory and time.

如果程序一直不改变这个字符串 - 这是一件很寻常的事 - 程序就永不会复制过去,这样就节省了内存和时间。


Dead Object Detection is the process of sweeping through all the objects, variables, and whatnot inside of Parrot, and deciding which ones are in use and which ones aren't. The ones that aren't in use are then freed up for later reuse. (After they're destroyed, if active destruction is warranted.)

Dead Object Detection(废弃对象侦查)是一个扫描所有对象,变量和不是 Parrot 内部的东西,然后决定哪些是正在使用和哪些不是的过程。那些不在用的东西将被释放以等待下次的重新使用。(在它们被销毁之后,如果积极销毁是有担保的。)

See also: "GC"


Garbage Collection is the process of sweeping through all the active objects, variables, and structures, marking the memory they're using as in use, and all other memory is freed up for later reuse.

Garbage Collection(碎片收集)是一个扫描所有有效对象,变量和结构的过程,标记它们使用的内存为正在使用,而释放其他所有的内存,为下一次的重新使用。

Garbage Collection and Dead Object Detection are separate in Parrot, since we generally chew through memory segments faster than we chew through objects. (This is a characteristic peculiar to Perl and other languages that do string processing. Other languages chew through objects faster than memory)

Garbage Collection 和 Dead Object Detection 在 Parrot 中是分离开来的,因为我们通常认为从内存段中读取比从对象中读取要快。(这里有一个 Perl 和其他语言所有的特权是是做字符串处理。其他语言读取对象比内存快。)

See also: "DOD"


International Components for Unicode

Unicode 国际组件

ICU is a C and C++ library that provides support for Unicode on a variety of platforms. It was added to Parrot with the 0.0.8 release to provide future unicode support.

ICU 是一个 C 与 C++ 库,用来支持在不同平台上的 Unicode。它在 0.0.8 版本中被增加到Parrot用来支持未来的Unicode。



Parrot Intermediate Code. A medium-level assembly language for Parrot that hides messy details like register allocation so language compiler writers who target IMC don't have to roll their own.

Parrot Intermediate Code(Parrot中间码)。一个中等级别的汇编语言用来给Parrot隐藏杂乱的细节如寄存器分配,这样那些以 IMC 为目标的语言编译器作者就不用考虑这些。

See also IMCC, PIR.


Parrot's Intermediate Code Compiler, which started its life as an improved Parrot assembler, and eventually became so integrated with Parrot that it became the Parrot executable (being able to load and run PBC files, PASM files or IMC files).

Parrot's Intermediate Code Compiler(Parrot中间码编译器),它开始只当自己是一个改良的 Parrot 汇编器,而最后成为 Parrot 的一部分且成为可执行的 Parrot(它能加载和运行 PBC, PASM, IMC 文件)。


Another name for a PBC file, due to the names used for data structures in one of the early implementations. You can see the initial commit of the PackFile.pm implementation, with the rationale for the name here:

PBC 文件的另一个名字,因为此名字用于某一早期实现中的数据结构。您可以参见实现 PackFile.pm 的最初提案,取为此名的基本原理在此



Parrot Byte Code. The name for the "executable" files that can be passed to the Parrot interpreter for immediate execution (although PASM and IMC files can be executed directly, too).

Parrot Byte Code(Parrot二进制代码). 此名是因为它是一个可执行的文件,可以直接在 Parrot 解释器上运行( PASM 和 IMC 文件也可以被直接运行)。

See also Packfile.


Parrot Intermediate Representation. The original name for IMC. Since it has become the convention to name input files to IMCC with the extension ".imc", IMC is a more natural name, although PIR is still sighted regularly on the <[email protected]> email list.

Parrot Intermediate Representation(Parrot中间表示)。IMC 最初的名字。因为命名一个输入文件为带 ".imc" 后缀的 IMCC 是一个习惯性的约定。IMC 是个更自然的名字,但是 PIR 仍然经常性的在 <[email protected]> 邮件列表中看见。

See also IMC.


PMC is an acronym for Parrot Magic Cookie. (Or Cracker, your choice.) PMC classes are the primitives that Parrot-based languages use to represent their fundamental types, such as Perl's scalar values.

PMC 是 Parrot Magic Cookie(Or Cracker, 随您选择.)的缩写。 PMC 类是最原始的,这基于Parrot的语言用来表述最基本的类型,类如Perl的标量值($)。


A bytecode transformation technique which reduces the amount of pointer dereferencing done in the inner loop of the interpreter by pre-converting opcode numbers into pointers to their opfuncs, and also converting the register numbers and constant numbers in the arguments to the ops into pointers.

一种字节码的转换技术,通过预先转换操作代码号到操作函数的指针和转换传递给操作的参数中的寄存器号和常量为指针,它减少了在解释器的内部循环中的指针反引用/pointer dereferencing的次数。

The original implementation by Gregor Purdy was posted on 2001-12-11. On one test system, it resulted in a 22% speed increase on a test program with a tight inner loop.

Gregor Purdy 写的最初的实现发表于 2001-12-11。在一个测试系统上,对一个有紧内部循环的程序,它的执行结果有22%的速度提升。

http:[email protected]/msg06941.html

On 2001-12-18, predereferencing got a speed boost (to about 47% faster than the regular DO_OP inner loop -- without compiler optimizations turned on). This was due to an off-list (actually over lunch) suggestion by John Kennedy that instead of pre-initializing the new copy of the bytecode with NULL pointers, we pre-initialize it with pointers to a pseudo-opfunc that does the predereferencing whenever it is encountered.

在2001-12-18, predereferencing 得到一个速度提升(大约比普通 DO_OP 内部循环快47% --- 没有开启编译器优化)。这归功于一个由 John Kennedy 写的 off-list(actually over lunch) 建议,我们预先初始化一个指针到一个当遇上时才 predereferencing 的假操作函数,来代替旧的通过 NULL 指针预先初始化新的字节码拷贝。

On 2002-04-11, Jason Gloudon suggested combining aspects of the Computed Goto Core and the Prederef[erencing] Core.

在 2002-04-11, Jason Gloudon 建议整合 Computed Goto 核心和 Prederef[erencing] 核心。

http:[email protected]/msg07064.html

The week of 2003-02-09, Leopold Totsch combined Computed Goto and Predereferencing to produce the CGP core.

2003-02-09 的这周, Leopold Totsch 整合了 Computed Goto 和 Predereferencing 而发布 CGP 核心。


Later, on 2003-02-14, Leopold Totsch and Nicholas Clark combined the JIT and the Computed Goto Prederef cores to great effect.

迟些时间,在 2003-02-14,Leopold Totsch and Nicholas Clark 组合了 JIT(just-in-time)和 Computed Goto Prederef 核心,取得了很大成果。



A table of operations attached to some data types, such as PMCs and strings. Vtables are used to avoid using switches or long if chains to handle different data types. They're similar to method calls, except that their names are pre-selected.

一个与某些数据类型相连的操作符表,类如 PMCs 和字符串。Vtables 是用来避免使用 switch 或者极长的 if 链来处理不同的数据类型。它与方法调用有些相似,不同的是他们的名字是预先选定的。

Warnock's Dilemma

The dilemma you face when posting a message to a public forum about something and not even getting an acknowledgment of its existence. This leaves you wondering if your problem is unimportant or previously addressed, if everyone's waiting on someone else to answer you, or if maybe your mail never actually made it to anyone else in the forum.



Please send corrections to the perl6-internals mailing list.

请将您修正后的结果发送至 perl6-internals 邮件列表。


中文译文中的错误请发到 fayland_at_gmail_dot_com

blog comments powered by Disqus