Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Smalltalk handle program error?

I'm a newbie on Smalltalk. I have read some articles and documents about it and I am surprised about its completeness of concepts. And it offers some kind of live debugging.

Anyway, for program errors, the error means the program logic is wrong, and all accumulated mutations by the program are all invalid. To guarantee integrity, the whole program should be restarted from some point, and the whole program state should be rollback.

How does Smalltalk handle this? (maybe this question can be applied to all dynamic REPL languages...)

like image 863
eonil Avatar asked Jun 13 '11 17:06

eonil


1 Answers

Smalltalk uses Exception objects. I recommend you to read the chapter about that https://gforge.inria.fr/frs/download.php/26600/PBE2-Exceptions-2010-03-02.pdf

it is part of the Pharo By Example book: http://pharobyexample.org/

Regarding the mutation, debugging, etc, note that Smalltalk reifies lot of stuff in the language. For example, the MethodContext class. Those objects reprents the method contexts that the VM is executing. So you can inspect them, and play with them just as a regular objects. The same with CompiledMethod. Just for fun, inspect the "pseudo" variable 'thisContext' :)

IF you want to answer your answers yourself, take a look to the Debugger class. So, do you want to know what happens when you restart the method in the middle of the debugger? then browse the method #restart in Debugger and follow :)

like image 65
Mariano Martinez Peck Avatar answered Dec 08 '22 00:12

Mariano Martinez Peck