奇怪的厨师退出行为

Strange Cuis quit behaviour

使用 Cuis 进行试验时,我发现:

如果我单独评估,在一个作品space中,下面的语句,Smalltalks正确地保存了它的图像,然后它退出了。

Smalltalk saveSession.
Smalltalk quitPrimitive.

但是,如果我 select 两个陈述然后我尝试一起做, Smalltalks 保存了图像,但没有退出。

如果我尝试执行以下语句,也会发生同样的事情:

Smalltalk saveSession; quitPrimitive.

有什么解释吗?

恢复 Smalltalk 映像意味着继续它在保存时所做的任何事情。 "Saving"表示占用当前对象内存的"snapshot"。

Smalltalk saveSession.
"<-- execution frozen here, this is what happens at startup"
Smalltalk quitPrimitive.

如果在一个表达式中调用save和quit,那么它会先快照,然后在启动时执行quit。如果您单独执行快照,它将在启动时恢复 运行 用户界面:

Smalltalk saveSession.
"<-- execution frozen here, nothing more happens at startup"

第二个表达式没有计算,所以它不是"in the snapshot"。

基本上 Smalltalk 会在它停止的地方启动 - 没有 main 函数像在其他编程语言中那样首先执行。 Smalltalk的执行只是在snapshot方法中间"frozen",再次启动image时,在snapshot方法中还是still,正常只是returns。

参见 SystemDictionary>>snapshot:andQuit:embedded:

snapshotPrimitive returns 时,该方法会启动。你可以看到启动列表是在快照之后处理的,当图像是 "started".

时,这将作为第一件事发生