Skip to content

Instantly share code, notes, and snippets.

@dander
Created September 10, 2018 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dander/bfd57481b9a52ddf13e27b5bf4ae94f4 to your computer and use it in GitHub Desktop.
Save dander/bfd57481b9a52ddf13e27b5bf4ae94f4 to your computer and use it in GitHub Desktop.
Attempting to produce a simple / concise explanation of words in Red

What are words?

Words form the grammar of the Red programming language. For people familiar with more mainstream languages, word! replaces keywords, variables, and operators. However, unlike other programming languages where those constructs have fixed definitions hard-wired in the compiler, in Red words are just a basic type of data. This makes the structure of a program extremely flexible.

Parts of a word!

A word! is made of up of 3 basic parts.

  • name - The symbolic representation of the word. It's just the text that you typed to create the word
  • context - This determines the meaning of the word. Just as in spoken language, a word can change its meaning depending on the context. In Red, a context is a mapping of words to their meanings.
  • value - This is the meaning of the word; it can be any Red value. When a word is evaluated (as code), its name is looked up in the associated context, then if it is a function it will be invoked. Otherwise the corresponding value is returned.

What is a Binding?

A binding associates a word to the context where it gets its value. You can change the meaning of a word by binding it to a different context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment