1. 10
  1.  

  2. 1

    This is probably a dumb question, but what’s wrong with passing an anonymous word to the activate-toaster word?

    [ my-custom-code-here ] activate-toaster
    
    1. 2

      That’s what I’d do, too. and then I would just : warm-toaster [ warm ] activate-toaster ; and do forth like Chuck would. At uni I wrote a lot of Forth esp on FlashForth and such and never ever found myself ever using defer, hooks and such, because they are anti-patterns imo.

      1. 1

        Hooks are best used when you have something you need to be able to temporarily replace. For instance, output. The c:put is a hookable word. By setting a new target, you can capture all displayed data until the word is unhooked to a buffer or file.

      2. 2

        I may well be misunderstanding the context here, but my understanding is that, while your solution would 100% work, it solves a different problem than what a hook seeks to solve – I imagine the scenario where, for example, a toaster manufacturer includes hooks in the toaster’s code that an enthusiast home-toaster-programmer could extend without having to gain direct access to the toaster’s core code. Your solution (I think) assumes direct access to the point of invocation of a word, whereas, with a hook, you could extend an existing interface without having to touch it directly.

        1. 1

          Think along the lines of git hooks.