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

**URL:** https://racket.discourse.group/t/whats-the-easiest-way-to-experience-tcr-in-drracket/1862
**Category:** Questions & Answers
**Tags:** question, drracket
**Created:** [April 13, 2023, 9:35am UTC](https://racket.discourse.group/t/whats-the-easiest-way-to-experience-tcr-in-drracket/1862 "2023-04-13T09:35:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![danprager](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/danprager/32/279_2.png) [@danprager](https://racket.discourse.group/u/danprager)
#### Post date: [April 13, 2023, 9:35am UTC](https://racket.discourse.group/t/whats-the-easiest-way-to-experience-tcr-in-drracket/1862/1 "2023-04-13T09:35:03Z")

</div>

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: [https://www.youtube.com/watch?v=Aof0F9DvTFg](https://www.youtube.com/watch?v=Aof0F9DvTFg)

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)

---

<div class="post-metadata">

### Author: ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)
#### Post date: [April 13, 2023, 1:00pm UTC](https://racket.discourse.group/t/whats-the-easiest-way-to-experience-tcr-in-drracket/1862/2 "2023-04-13T13:00:48Z")

</div>

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

---

<div class="post-metadata">

### Author: ![joeld](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/joeld/32/38_2.png) [@joeld](https://racket.discourse.group/u/joeld)
#### Post date: [April 13, 2023, 3:11pm UTC](https://racket.discourse.group/t/whats-the-easiest-way-to-experience-tcr-in-drracket/1862/3 "2023-04-13T15:11:34Z")

</div>

> [@danprager](#):
>
> - Run (traditional behaviour)
> - Detect: did any errors occur?
> - Yes: Revert (from file)
> - No: Save (to file)

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?

---

<div class="post-metadata">

### Author: ![spdegabrielle](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/spdegabrielle/32/95_2.png) [@spdegabrielle](https://racket.discourse.group/u/spdegabrielle)
#### Post date: [April 13, 2023, 10:07pm UTC](https://racket.discourse.group/t/whats-the-easiest-way-to-experience-tcr-in-drracket/1862/4 "2023-04-13T22:07:24Z")

</div>

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

> - **Revert** : Re-loads the file that is currently in the[definitions window](https://docs.racket-lang.org/drracket/interface-essentials.html#%28tech._definitions._window%29). All changes since the file was last saved will be lost.

[https://docs.racket-lang.org/drracket/Menus.html#(part.\_menu~3afile)](https://docs.racket-lang.org/drracket/Menus.html#%28part._menu~3afile%29)

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.”

[https://pkgs.racket-lang.org/package/Drrackgit](https://pkgs.racket-lang.org/package/Drrackgit)

See also [https://github.com/bbusching/libgit2](https://github.com/bbusching/libgit2)

# **DrSync** by Grant Rettke

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

[http://planet.racket-lang.org/package-source/grettke/drsync.plt/2/8/planet-docs/drsync/index.html](http://planet.racket-lang.org/package-source/grettke/drsync.plt/2/8/planet-docs/drsync/index.html)

[http://planet.racket-lang.org/display.ss?package=drsync.plt&owner=grettke](http://planet.racket-lang.org/display.ss?package=drsync.plt&owner=grettke)

Best regards

Stephen  
:beetle:
