## December 8, 2016

### Deferred Words

Traditional Forth systems have often supported deferred words via something like:

    DEFER test
    : square DUP * ;
    ' square IS test

[Retro 11](/retro/11) made all words into vectors, which are effectively deferred words with a default definition. In Retro 11, the above would look like:

    : test ;
    : square dup * ;
    &square is test

This didn't impact performance much since most of the Ngaro VM implementations have NOP skipping which lets them just advance to the first actual instruction in the default definition.

[RETRO 12](/retro/12) doesn't provide deferred words as part of the core language. But it's easy to add something for this.

````
:err:not-implemented (-)
  'ERROR:_Stub_function_not_implemented puts nl ;

{{
  :stub  err:not-implemented ;
---reveal---
  :defer (s-)
    d:create &stub compile:jump compile:ret &class:word reclass ;
  :implement (as-)
    d:lookup d:xt fetch n:inc store ;
}}
````

With this it's possible to implement:

    'test defer
    :square dup * ;
    &square 'test implement