REFAL

From swissChili
Revision as of 00:26, 16 April 2022 by SwissChili (talk | contribs) (Add cookbook link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

REFAL (Wikipedia) is a functional programming language designed around the idea of pattern matching. It was designed by Valentin Turchin in 1966 and first implemented in 1968.

This Wiki holds documentation for my implementation of REFAL. More information about how/why I wrote it is available on my website. The interpreter is written in C++ and available on Github.

Learn REFAL

There are a few good resources on REFAL for beginners available online:

  • The REFAL book by Valentin F. Turchin (inventor of REFAL), in English and Russian.
  • The (work in progress) REFAL Cookbook written by me (and maybe in the future, contributors).

Built-in Functions

These functions are pre-loaded into REFAL and can be used at any time. They are not identical to standard REFAL-5 functions: some changes have been made for simplicity's sake.

Input & Output Functions

  • <Print e.Expr> Prints the expression to standard output. Returns e.Expr.
  • <Prout e.Expr> Prints the expression to standard output. Returns an empty expression.

Stack (variable) Manipulation Functions

  • <Br s.Name '=' e.Value> Pushes the variable s.Name onto the stack with the value e.Value
  • <Dg s.Name> "Digs" (pops) the variable s.Name off the stack. Returns the value associated with s.Name
  • <Cp s.Name> Copies the variable s.Name, returns value associated with s.Name. Unlike <Dg> this does not remove the variable from the stack.