What's the easiest way to experience TCR in DrRacket?

Is there a neat way to try out the TCR (Test & Commit or Revert) in Dr Racket?

TCR test && commit || revert is an alternative programming workflow similar to TDD. Run the tests after every change. If they pass, commit. If they fail, revert to the last passing state. As you'll see, this means that changes that don't work just poof disappear. Putting changes at risk creates a powerful incentive to make changes in teensy tiny steps.

Here's Kent "XP" Beck demo-ing TCR in Python (and Vim?) with the desired behaviour: TCR test && commit || revert -- Rope in Python 1/3 - YouTube

Maybe a small plugin?

The traditional way would involve a version control system, but for trying-it-out-purposes all that would be necessary is to alter the behaviour of Run to:

  1. Run (traditional behaviour)
  2. Detect: did any errors occur?
  3. Yes: Revert (from file)
  4. No: Save (to file)
1 Like

The editor in that video is VS Code (not Vim, sadly :P).

I watched the linked video. He never runs into the obvious failure mode of trying something, having it fail & revert due to a typo, and having to type it all over again instead of just fixing the typo. And at around the 16min mark he admits that he practiced running through it a few times before recording. Maybe he demonstrates what that’s like in Part 2 or 3?

1 Like

The File menu in DrRacket includes Revert which would support the simplified process you describe.

  • Revert : Re-loads the file that is currently in thedefinitions window. All changes since the file was last saved will be lost.


To support the full TCR test && commit || revert workflow you might be interested in the following DrRacket plugins:

Drrackgit by Bradley Busching

“A git plugin for DrRacket.”


See also https://github.com/bbusching/libgit2

DrSync by Grant Rettke

“DrSync reverts your files when DrRacket’s frame activates and saves them when it deactivates”



Best regards