From the Vassili Bykov's article "The hitch hiker's guide to the smalltalk compiler" http://www.smalltalkchronicles.net/edition2-1/st_compiler.htm,
"Assertions are trivial to implement as a message assert sent to a block, with the assert method defined either as a real test or as a no-op . We will implement a fancier version, to satisfy the following requirements.
The use of assertions should impose zero overhead. When the assertion preference is off, compiled methods should contain no traces of assertion code.
When assertions are on, assertion code is inlined in the containing method.
When the assertion setting is changed, all methods containing assertions are automatically recompiled.
Assertion failure signals an AssertionFailedError exception. ... [Assertions] substitutes a special kind of program node, AssertionNode, in place of the original assert: message send. AssertionNode takes care of generating (or not generating) the inlined assertion code. ... Squeak handles special selectors in a way different from VisualWorks, which makes the [implemtation] more interesting."
Romain Robbes on March 08, 2004 published Vassili Bykov's Assertions on SqueakMap Vassili [wrote his code using]Squeak 2.7, so it was really a long time ago :-). So I made a release for squeak 3.7, adding a preference to toggle it on or off (in the debug category), and providing unit tests for it. The port was An extremely harassing task, as I only had to simplify one method :-). If only it could be like that more often ...