请输入您要查询的百科知识:

 

词条 Thunk
释义

thunk:PC计算机中典型的形实转换程序。在电脑里,为了执行指令,需要在内存段地址和平坦地址之间进行转换。当16位应用程序在32位地址空间进行运行的时候,应用程序的16位段地址必须转化成32位平坦地址,这时候thunk是很容易见到的。另外,如果一个32位程序呼叫一个16位DLL,那么thunk就存在于相反的方向:从32位转变成16位。

基本解释

简单的说叫 形实转换程序,给一个类创建对象,这是我的理解。而在WINDOWS里边意味着16/32位程序的转换。

详尽解释

thunk中英解释

In a PC, to execute the instructions required to switch between segmented addressing of memory and flat addressing. A thunk typically occurs when a 16-bit application is running in a 32-bit address space, and its 16-bit segmented address must be converted into a full 32-bit flat address. On the other hand, if a 32-bit program calls a 16-bit DLL, then the thunk is in the opposite direction: from 32 bit to 16 bit.

相关的历史

thunk

1. [obs.]“A piece of coding which provides an address:”, according to P. Z. Ingerman, who invented thunks in 1961 as a way of binding actual parameters to their formal definitions in Algol-60 procedure calls. If a procedure is called with an expression in the place of a formal parameter, the compiler generates a thunk which computes the expression and leaves the address of the result in some standard location.

"只是编写可提供地址的代码的一部分:”,P.Z.Ingerman如是说。他是在1961年发明这个定义的。当时是定义这样一个方法:把实际参数绑定到在Algol-60程序里呼叫到的定义。如果一个程序在被呼叫的时候,用一个表达式占据了形参的位置,那么编译器就会产生一个thunk,这个thunk指的是:计算表达式的地址,然后把这个地址放在适宜的位置。

2. Later generalized into: an expression, frozen together with its environment, for later evaluation if and when needed (similar to what in techspeak is called a closure). The process of unfreezing these thunks is called forcing.

过了不久,它的意思就扩大了:一个表达式,被它所在的环境所限制,在需要的时候重新计算这个表达式的值(有点象techspeak里的closure(关于closure参考下面。))。完成这些thunks的过程就称为forcing。(什么东东?强迫?暴力?望指教)

3. A stubroutine, in an overlay programming environment, that loads and jumps to the correct overlay. Compare trampoline.

stubroutine(stub subroutine的缩写,是subroutine(参考后文)的占位符,通常很小,或者为空,在后来被充实),通常存在于外壳编程环境,它装载并跳转到正确的外壳。好比蹦床。

4. Microsoft and IBM have both defined, in their Intel-based systems, a “16-bit environment” (with bletcherous segment registers and 64K address limits) and a “32-bit environment” (with flat addressing and semi-real memory management). The two environments can both be running on the same computer and OS (thanks to what is called, in the Microsoft world, WOW which stands for Windows On Windows). MS and IBM have both decided that the process of getting from 16- to 32-bit and vice versa is called a “thunk”; for Windows 95, there is even a tool THUNK.EXE called a “thunk compiler”.

Microsoft和IBM对它都进行了定义,在基于Intel的系统里,一个“16位环境”(使用bletcherous的段寄存器,并且有64K地址的限制)和一个“32位环境”(使用平坦地址,并且实现半真实内存管理功能)。这两个环境都能在同样的电脑和OS(顾名思义,在Microsoft的世界,WOW指的是Windows On Windows)。MS和IBM都决定把---从16位到32位和32位到16位的转变---叫做“thunk”;

就Windows 95而言,甚至还有一个工具THUNK.EXE被称为“thunk编译器”。

5. A person or activity scheduled in a thunklike manner. “It occurred to me the other day that I am rather accurately modeled by a thunk — I frequently need to be forced to completion.:” — paraphrased from a plan file.

Historical note: There are a couple of onomatopoeic myths circulating about the origin of this term. The most common is that it is the sound made by data hitting the stack; another holds that the sound is that of the data hitting an accumulator. Yet another suggests that it is the sound of the expression being unfrozen at argument-evaluation time. In fact, according to the inventors, it was coined after they realized (in the wee hours after hours of discussion) that the type of an argument in Algol-60 could be figured out in advance with a little compile-time thought, simplifying the evaluation machinery. In other words, it had ‘already been thought of’; thus it was christened a thunk, which is “the past tense of ‘think’ at two in the morning”.

closure

In programming languages, a closure is a function that refers to free variables in its lexical context.

在程序设计里,closure是一个函数。这个函数在其上下文中涉及到了释放变量。

A closure is usually a function created by a program at run time. This is best demonstrated by a function that appears entirely within the body of another function. The nested, inner function must refer to local variables of the outer function. As the outer function executes, it creates a new instance of the inner function. If that inner function refers to some of the local variables of the outer function, a closure is formed. It consists of the function code and a reference to any variables in the outer function's scope that the closure needs.

Closures are commonly used in functional programming to defer calculation, to hide state, and as arguments to higher-order functions.

Several object-oriented techniques and language features simulate some features of closures. For example:

In [[C++]], programmers may define function objects by overloading operator(). These objects behave somewhat like functions in a functional programming language. They may be created at runtime and may contain state. However, they do not implicitly capture local variables as closures do. Two proposals to introduce C++ language support for closures (both proposals call them lambda functions) are being considered by the C++ Standards Committee [1], [2]. The main difference between these proposals is that one stores a copy of all the local variables in a closure by default, and another stores references to original variables. Both provide functionality to override the default behaviour. If some form of these proposals is accepted, one would be able to write

void foo(string myname) {

typedef vector names;

int y;

names n;

// ...

names::iterator i =

find_if(n.begin(), n.end(), <>(const string& s){return s != myname && s.size() > y;});

// i is now either n.end() or points to the first string in n

// which is not equal to myname and which length is greater than y

}

Java allows the programmer to define "anonymous classes" inside a method; an anonymous class may refer to names in lexically enclosing classes, or final variables in the lexically enclosing method.

class CalculationWindow extends JFrame {

private JButton btnSave;

...

public final calculateInSeparateThread(final URI uri) {

// The expression "new Runnable() { ... }" is an anonymous class.

Runnable runner = new Runnable() {

void run() {

// It can access final local variables:

calculate(uri);

// It can access private fields of the enclosing class:

btnSave.setEnabled(true);

}

};

new Thread(runner).start();

}

}

Subroutine:

A set of instructions that performs a specific task for a main routine, requiring direction back to the proper place in the main routine on completion of the task.

一组为主程序完成某项特定任务的指令集合,任务一旦完成需要跳转回主程序合适的地方。

bletcherous:

Disgusting in design or function; esthetically unappealing. This word is seldom used of people. “This keyboard is bletcherous!” (Perhaps the keys don't work very well, or are misplaced.)

在设计或者是功能上的不满;挑剔式的抱怨。这个词人们通常都不怎么使用。如

“这个键盘有点bletcherous!”

随便看

 

百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。

 

Copyright © 2004-2023 Cnenc.net All Rights Reserved
更新时间:2024/11/16 5:56:01