Inspired by Andreas Wagner’s ecr word, I created the word go:
\ go.fs
: go#empty s" ---marker--- marker ---marker---" evaluate ;
: go#open s" vim my_project.fs" system ;
: go#run s" my_project.fs" included ;
: go go#empty go#open go#run ;
marker ---marker---
marker ---marker--- defines a special word: ---marker---
- When executed, it makes Forth forget all definitions made after it (including itself).
The go word orchestrates an edit-reload cycle:
go#emptyis the clever bit.- It
evaluate-s the string"---marker--- marker ---marker---". - This first runs the existing
---marker---(clearing definitions from the previous load ofmy_project.fs). - Then it defines a new
---marker---at the now-empty top of the dictionary, priming it for the next cycle.
- It
go#openusesgforth’ssystemto openmy_project.fsin vim.go#runusesincludedto load the freshly editedmy_project.fs.