Skip to content

Instantly share code, notes, and snippets.

@crcx
Created September 12, 2010 13:45
Show Gist options
  • Save crcx/576122 to your computer and use it in GitHub Desktop.
Save crcx/576122 to your computer and use it in GitHub Desktop.
Notes on the Creation and Use of Vocabularies in Retro

Overview

In 10.7 (and beyond) the vocabulary system in Retro has been significantly altered. Prior releases provided nestable, collapsible subsets of the global dictionary. The new approach differs by:

  • no nesting
  • each vocabulary is a separate dictionary list
  • user controllable search order

Creating a Vocabulary

chain: name
  ... functions and variables ...
;chain

A new vocabulary is created using chain: and ends with ;chain. Any functions or variables you define between these will become part of the vocabulary and are removed from the global dictionary.

By convention, vocabulary names should end with a single apostrophe (').

When creating a vocabulary, you can use the normal namespace functions to manage visibility of functions and variables. {, {{, }}, }, ---reveal---, and hide will all work as expected.

Using a Vocabulary

You can switch from the global dictionary to a specific vocabulary by using the name of the vocabulary directly, or add a vocabulary to the search order.

Switching to a Vocabulary

name'
  ...code...
%%

The use of %% will switch you back to the global dictionary.

This approach is not recommended for general coding. The preferred way is to add a vocabulary to the search order.

Controlling the Search Order

Add a Vocabulary to the Search Order

with name'

This will add the functions in name' to the search order used by find and other functions. Vocabularies are searched first, then the global dictionary. The most recently added vocabulary will be searched first.

Remove a Vocabulary from the Search Order

without

This will remove the most recently added vocabulary from the search order. If you have several vocabularies loaded and want to quickly return to just the global dictionary, use global instead:

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