Charles Childers


blog | parable | retro | ios apps | fountain pens


RETRO

Retro is a modern dialect of Forth. Two generations are currently being developed and supported.

RETRO 11

This is the older and more mature system. It has been refined through use and includes extensive documentation, examples, and libraries to expand functionality. It also has broader platform compatibility thanks to the many implementations of the Ngaro virtual machine it runs on.

RETRO 12

RETRO 12 is a complete rewrite of the language. It runs on a new virtual machine (Nga), has a smaller and less complex core, and is designed from the beginning to work with quotations and combinators as primary language elements.

› Comparisons

Syntax For RETRO 11 RETRO 12
Numbers -12 #-12
Characters 'C $C
Strings "Hello" 'Hello
Comments ( test ) (test)
Pointer &Name &Name
Namespaces ^namespace'function namespace:function
Definitions : name ... ; :name ... ;
Variables variable name 'name var
Constants 10 constant BASE #10 'BASE const
Quotes [ ... ] [ ... ]

Below are some code samples to help you get a better feel for the differences.

  R11                           R12
  -------------------------  |  -------------------------
  : <factorial>              |  :<factorial>
    dup 1 = if; dup 1-       |    dup #1 -eq? 0; drop
    <factorial> ;            |    dup n:dec <factorial> ;
  : factorial                |  :factorial
    dup 0 =                  |    dup zero?
    [ 1+ ]                   |    [ n:inc ]
    [ <factorial> ] if ;     |    [ <factorial> ] choose ;
  -------------------------  |  -------------------------
  with strings'              |  'hello 'world str:append
  "hello" "world" append     |
                             |
  "hello_world" getLength    |  'hello_world str:length
                             |
  "hello_world" reverse      |  'hello_world str:reverse
  -------------------------  |  -------------------------
  needs char'                |
  'C ^char'isUpper?          |  $C chr:is-uppercase?
  'H ^char'toString          |  $H chr:to-string
  -------------------------  |  -------------------------