分享
 
 
 

Thunk

王朝百科·作者佚名  2010-06-26
窄屏简体版  字體: |||超大  

简单的说叫 形实转换程序,给一个类创建对象,这是我的理解。而在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.

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

相关的历史:

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!”

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有