RETRO FORTH

About

RETRO is a modern, pragmatic Forth drawing influences from many sources. It's clean, elegant, tiny, easy to grasp, and adaptable to many tasks.

It's not a traditional Forth. Drawing influence from colorForth, it uses prefixes to guide the compiler. From Joy and Factor, it uses quotations (anonymous, nestable functions) and combinators (functions that operate on functions) for much of the stack and flow control. It also adds vocabularies for working with strings, arrays, and other data types.

Download

Latest Source (recommended)

2019.1 Release

Documentation

Read the RETRO Handbook

Glossary (text)

Glossary (Browsable, HTML)

Features

Open Source

The source and documentation are distributed under the ISC license.

Portable

RETRO runs on a virtual machine. Implementations are provided in C, Python, Pascal, C#, JavaScript, and RETRO.

RETRO has been built and used on many systems including DOS, Windows, Linux, FreeBSD, NetBSD, Haiku, macOS, and iOS. Tested host CPU architectures include x86 (16 and 32 bit), x86-64, ARM, and PowerPC.

Self Contained

The standard binaries are entirely self contained and need only standard system libraries to run.

Small

RETRO is small, in both source and binaries.

A minimal C implementation of the VM is 250 lines (without comments). The full implementation is 2,376 lines. On FreeBSD x86-64, the binaries can range from 55k to 128k in size depending on configuration.

Code Sample

LISP provides a function, `defstruct`, which creates a data
structure and functions for accessing various fields in it.
This can be useful, so I'm doing something similar here.

(defstruct book title author subject book-id )

~~
{{ 
  :make-helper (nsq-)  [ d:create , ] dip does ; 
  :make-struct (ns-)
    d:create , [ here swap fetch allot ] does ; 
---reveal--- 
  :defstruct (sa-) 
    dup array:length 
    [ n:dec swap 
      [ 'ab 'aabab reorder 
        '@ s:append [ fetch + fetch ] make-helper 
        '! s:append [ fetch + store ] make-helper 
        n:dec 
      ] array:for-each drop 
    ] sip swap make-struct ; 
}} 
~~

```
'book { 'title 'author 'subject 'book-id } defstruct

book 'A const
"The_Hobbit     &A title!
"J.R.R._Tolkien &A author!
"Fantasy        &A subject!

:info (a-)
  [ subject@ ] [ author@ ] [ title@ ] tri
  '%s_by_%s_is_a_%s_book. s:format s:put nl ;

&A info
```

View more examples.


This site is served by Casket, an HTTP server written in RETRO.