by stcredzero · 10y ago · 0 comments
false ifTrue: [
"Some code to debug to help understand..."
].
In VisualWorks, you can double-click next to the 1st square bracket to select the code, then instantly execute it or debug it. The reason why it's not simply commented out, is that automated refactorings in the Smalltalk Refactoring Browser can then touch the commented-out code. (St RB used to be guaranteed to always execute strict refactorings and produce correct code.)Often such code can even use values from the current scope, so a separate debug session can be spawned to see what it "would have been like" then dismissed with no consequences. It's stuff like that which made Smalltalk an uber-environment back in the day.
(comment
(def some-state (create-state))
(some-fn [1 2 3])
(do-something some-state)
)
The compiler ignores the block, but in a REPL enabled editor, you can evaluate the forms to possibly view current state, or run functions that test behaviors or probe runtime state. #_(def some-state (create-state))
(some-fn [1 2 3])
(do-something some-state)) #_((def some-state (create-state))
(some-fn [1 2 3])
(do-something some-state))
oh, and you can't have "invalid" code in (comment), but in #_ you can.Didn't know about the difference in behaviour with regard to invalid code. Thanks for that.
EDIT: Leaving this here for context. I'd missed the fact that they weren't all enclosed in a single form to begin with. Parent's solution is correct in light of that.