Squeak
  links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Comment out code
Last updated at 3:31 pm UTC on 14 January 2006
A problem with comments in Smalltalk, and most other languages, is inability to comment out comments, something I often want to do.

This makes the unwanted code into an unused block:

 myMethod
| a b c |

    [
"the old implementation"
a := Float pi squared. "lots of pies"
b := 10.0 sqrt. "sqrt of 10"
c := a * b "a root pie"
].

I don't know if Squeak optimizes this out like it should though. – BobHartwig

I generally prefer doing something like

  myMethod
false ifTrue:[
"old implementation"
] ifFalse:[
"new implementation"
]

You can change this without adding and removing the closure. – Andreas Raab

My preference is to not clutter good, current code, with old, commented-out code. Recovering old code is supported by method history. - Chris Muller