Search code examples
forthgforth

Print definition of a function in Forth


When a word is already defined in Forth, is there a way to print its definition?

I've heard that many of Forth's built-in functions such as emit, drop, etc. are defined in terms of the language itself, and I'd like to be able to look at their definitions.


Solution

  • You can usually use

    see emit
    

    Which in Gforth gives you something like:

    : (emit)
      outfile-id emit-file drop ;
    latestxt
    Defer emit
    IS emit
     ok