Skiforth

From Esolang
Jump to navigation Jump to search

Skiforth is a SK-calculus based Forth discovered by User:Orby in April 2020.

Definitions

S and K are combinators. If x and y are combinators, then x y ` is a combinator.

  1. z y x S ` ` ` is rewritten to z y ` z x ` `
  2. y x K ` ` is rewritten to x

Words

All words must be separated by whitespace. All words are case insensitive. Skiforth uses post-fix notation. There are 10 built-in words including the ability to define new ones:

  1. S pushes the S combinator onto the stack.
  2. K pushes the K combinator onto the stack.
  3. ` applies the first combinator on the stack to the second combinator on the stack.
  4. : begins a word definition.
  5. ; ends a word definition.
  6. . pops the first combinator off the stack and prints it.
  7. ( begins a comment.
  8. ) ends a comment.
  9. include file includes a file.
  10. list lists the content of the dictionary.
  11. bye exits the interpreter.

Examples

The I combinator (SKK) is not a built-in command. We can define it by typing

: I K K S ` ` ;
ok

The first token after : is the name of the word. All subsequent tokens until ; compose the body of the word. Let's look at what we created

I .
K K S ` ` ok

We can apply the I combinator to itself and print the result by typing

I I ` .
K K S ` ` ok

We can also redefine built-in commands

: S K S ` ` ;
ok

And redefine commands we've already defined recursively

: S K S ` ` ;
ok
: S K S ` ` ;
ok
S .
K K S ` `
ok

See also

  • Git repository for official Skiforth interpreter.
  • Bootable ISO which contains the Skiforth OS.
  • Unlambda is similar but uses prefix notation.