home *** CD-ROM | disk | FTP | other *** search
-
-
- A Quick Look At Fifth
- - ----- ---- -- -----
-
-
- -- The Philosophy of Fifth --
-
- Fifth is first and foremost a programmer's programming
- environment. Fifth is made up of a compiler, a text editor, a
- dictionary editor, and an interactive environment. These elements
- are highly integrated to produce the Fifth programming
- environment.
-
- Fifth as a language is very simple and very flexible. Fifth does
- not attempt to provide every structure a programmer might want.
- Instead, Fifth gives the programmer the tools to create any
- structure he/she needs at compile time, easily and efficiently.
-
- The main goal of Fifth is to eliminate the long edit-compile-
- debug times typical of compiled languages. This cycle is reduced
- in several ways:
-
- 1) Incremental Compilation. Fifth limits compiles to sections
- of code which have been changed, as they are changed, rather
- than requiring a recompilation of the entire program.
-
- 2) Efficient Use of Primary Memory. The entire Fifth system is
- very small and thus can remain in primary memory at all
- times. (Any portion of the system that is not required may
- be removed by the programmer to further reduce size.)
-
- 3) Fast Compilation. The Fifth compiler is extremely fast;
- Fifth code compiles an order of magnitude faster than
- conventional compilers.
-
- 4) Minimal Bookkeeping. The basis behind Fifth is very simple
- and natural. The programmer spends very little time keeping
- books.
-
-
- -- Programming in Fifth --
-
- Fifth has an extremely simple syntax. There are only two distinct
- syntactic constructs in Fifth: modules and numbers. modules and
- numbers must be separated by whitespace (blanks, tabs, carriage
- returns, linefeeds, or nulls). Thus the only syntax error
- possible is that of an invalid module or number.
-
- Programs are written in Fifth by writing modules using the
- primitive modules (the modules that come with the system) and
- other user defined modules. All modules are kept in a tree
- structured dictionary which defines the scoping of the modules.
- Both modules and the dictionary can be easily modified; Modules
- are altered using the module editor, and the dictionary using the
- dictionary editor.
-
- But what is a module? A Fifth module is like a subroutine or a
- procedure in other languages. But it is more. A module is made
- up of four parts:
-
- 1) The module name, which is used to reference the module. A
- name is made up of any combination of characters other than
- whitespace (Carriage returns, line feeds, nulls, blanks, and
- tabs).
-
- 2) The source code which defines the module,
-
- 3) The executable code which the compiler produces from the
- source code,
-
- 4) And a subdictionary which may contain submodules used in the
- module's definition.
-
- Numbers are combinations of digits and characters such that the
- same combination does not exist in the dictionary, and all
- characters are less than the current radix. There are two types
- of numbers, integers and reals. If the number contains a decimal
- or exponent, it's real; otherwise it's integer. Single precision
- numbers are in the range -2,147,483,648 to 2,147,483,647 and are
- 4 bytes long. The real numbers are also 32 bits. The precision is
- approximately 7 significant digits, and the exponent range is -38
- to +37.
-
-
- -- The Dictionary --
-
- Fifth's dictionary is an ideal data structure for programs. Both
- user defined modules and primitive modules (modules that come
- with the system) are contained in this structure. The source or
- text code for all modules is also kept in the dictionary. The
- scoping of a program is expressed directly in the dictionary, and
- can be easily examined and/or changed by using the dictionary
- editor. Thus what modules are accessible by a module is under
- programmer control through the Fifth programming environment.
-
- The Fifth dictionary is hierarchical; every module owns a
- subdictionary and belongs to another subdictionary, with the
- exception of the root module which owns the highest
- subdictionary. The owner of a particular subdictionary is called
- the local module of that subdictionary. The local module is the
- only module that has access its subdictionary. Thus a module in
- Fifth can be broken down into smaller logical parts, tied
- together by a main module, with all the parts in placed in the
- main module's subdictionary. When the main module is moved about
- in the dictionary, the subdictionary and all modules within the
- subdictionary are moved too.
-
- Thus programs in Fifth are written by building up modules from
- the primitive modules. Program development becomes a process of
- writing modules, testing them, moving them about in the
- dictionary, and using the new modules to write other modules.
- Thus elements of a program (modules) are modified using the
- module editor. The structure of the program is edited using the
- dictionary editor. This division is very natural, and the Fifth
- programming environment makes it easy.
-
-
- -- Scoping Rules --
-
- In general, scoping is a term used to describe what what
- programming structures can or can not be accessed from any
- position in a program. Many languages use global scoping, which
- means that all subprograms or routines can access all other
- subprograms or routines. In large programs (and even small
- programs) this can lead to problems.
-
- Fifth uses scoping rules that are similar to Pascal's. In Fifth,
- scoping is defined by a module's position in the dictionary. This
- section discusses how the dictionary is used to define the
- scoping of a program.
-
- Each module in Fifth contains a subdictionary, which is simply a
- list of other modules. (This list can be empty.) The modules in
- the subdictionary are available only to the local module, and no
- other module outside the subdictionary.
-
- When a module is is used in a definition, the module's definition
- is needed. The Fifth system attempts to find the module by doing
- a name search in the dictionary. The search starts in the
- subdictionary of the module being defined. If the definition is
- not found, successively higher subdictionaries are searched, up
- to the root module, which is local to the highest subdictionary.
- If no definition is found for the module, (and the module is not
- a valid number) it is considered undefined. That is, the module
- may exist somewhere in the dictionary, but is considered
- undefined if it is not in the search path.
-
-
- FIFTH
- |
- |
- { A B C }
- | | |
- | | +--------------------------+
- | +------------+ |
- | | |
- { D E F } { G H I } { J K }
- | | |
- | +--+ |
- | | |
- { L } { M N } { O P }
-
- Figure 1.1
-
-
- For example, suppose the dictionary looked something like figure
- 1.1. The dictionary search starts with the lowest module
- accessible from the local module, and proceeds to the left, then
- upward, until the root module is reached. The search NEVER goes
- down, nor to the right. Suppose that {M} in figure 1.1 attempts
- to use the undefined module {X}. The modules examined while
- searching for {X} are, in order: {M}, {I}, {H}, {G}, {B}, {A},
- and {FIFTH}. In this case M is the lowest accessible module,
- since {M}'s subdictionary is empty. But suppose that {K}
- attempted to use {A}. This time the search path is {P}, {O}, {K},
- {J}, {C}, {B}, and {A}. Notice had we been searching for {M},
- with {K} as the local module, {M} would be considered undefined.
-
- About the easiest way to learn the Fifth system is to jump on and
- start using it. Fifth places a high priority on speed, power,
- and flexibility, but it is very easy to use and learn. As you
- read through the manual, try out the examples. As quick as you
- can, write programs. You will find that using bit and pieces of
- the supplied programs quite easy and useful.
-
-
- -- The Dictionary Editor --
-
- The dictionary editor allows the programmer to edit Fifth's
- dictionary. The following is a bit of terminology which will make
- explanation of the dictionary editor and its use easier.
-
-
- -- Terminology --
-
- Before the dictionary is altered by the programmer, it has only
- the root module, and its subdictionary. The root module is
- originally called {FIFTH}, and the root module's subdictionary
- holds only the primitive modules.
-
- ( Primitive modules are all those modules basic to Fifth.
- Primitives differ from user defined modules in that they come
- with the system, and do not have subdictionaries of their own.)
-
- When the programmer brings up the Fifth system for the first
- time, {FIFTH}, the root module, becomes the local module. The
- text for the local module may be edited and compiled. Submodules
- may be created, deleted, renamed, and moved in the local module's
- subdictionary.
-
- A submodule may be inspected, in which case it becomes the local
- module, complete with its own subdictionary. The local module
- may be exited, in which case the parent module (The module
- "above") again becomes the local module.
-
- The local module specifies what modules are visible from the
- interactive environment. The interactive environment has access
- to a module if and only if the local module has access to that
- module. Thus the interactive mode is an excellent place to test
- modules and their interactions. As a reminder, the prompt in the
- interactive mode is made up of the name of the local module
- followed by a '>' symbol. Thus if {FIFTH} is the local module,
- the prompt in the interactive mode will be:
-
- FIFTH>
-
- The behavior of the interactive mode is much the same as most
- other FORTH systems. Any sequence of modules may be entered and
- executed. New modules may be defined, the local module may be
- redefined, etc.
-
- The dictionary editor is invoked by entering the module {DIR}
- form the interactive environment. It displays all the modules in
- the local dictionary (The subdictionary of the local module).
- Modules in the local dictionary may be selected with the right
- and left arrows. When a module is selected, it is shown in
- reverse video. The local module appears in reverse video in the
- top left hand corner of the screen. Also shown are status flags
- for the local module. These are summarized in figure(3.1)
-
-
- Flags - bits 0-F
- 0 - This link contains a valid entry
- 1 - Primitive module, no subdictionary,
- never needs compilation
- and has no text.
- 2 - Not compiled. This module failed
- compilation for some reason.
- 3 - No text. This module was created
- from the interactive environment,
- or has had its text striped off.
- This module cannot be recompiled.
- 4 - Header created by text, used while
- compiling from text.
- 5 - Suitable for inline coding.
- 6 - Immediate module.
- 7 - Compiler only module.
- 8 - Trace mode on.
- 9 - This module has 8087 alternate code
- in the parameter field.
-
- Figure 3.1
-
-
- The following is a list of keys and the functions they invoke
- while in the dictionary editor.
-
- Left/right arrow - Selects a module.
-
- Up arrow - raises to the parent dictionary, up to the root. If
- the root module is the local module, this key does nothing.
-
- Down arrow - lowers into the dictionary of the selected
- submodule.
-
- Ctrl left/right (IBM PC) or shifted left/right arrows (TI PC) -
- move the selected submodule left or right. This feature
- allows the submodules to be re-ordered.
-
- Ctrl page up (IBM PC) or shifted up arrow (TI PC) - move the
- selected submodule up in the dictionary, after the local
- module in the subdictionary of the submodule previous to it.
-
- Ctrl page down (IBM PC) or shifted down arrow (TI PC) - move the
- selected submodule into the dictionary of the submodule
- previous to it, moving the submodule farther from the ROOT
- dictionary.
-
- ESC - return to the interactive mode.
-
- C - compiles the local module. Compiler errors are possible. If
- the compiler finds an error, an error message is displayed,
- and Fifth returns to the interactive mode.
-
- Del or D - deletes the selected submodule and all of it's
- subdictionaries. All submodules after the deleted submodule
- are marked as not compiled.
-
- E- edits the text of the local module. See module Editor.
-
- Ins or I - allows a new submodule to be created in front of the
- selected submodule, or the local module to be (re)created.
-
- G - Executes the local module as if typed from the interactive
- environment. Note that G provides no method of placing
- values on the stack, thus routines expecting values on the
- stack will not execute properly in most cases.
-
- L - redirects the input stream to the specified file. This
- allows any text file to become input to Fifth. Text loaded
- is NOT compiled. However, if the loaded text redefines
- modules used by the load text routine, unexpected results
- can occur. Be especially careful about naming modules {UP},
- {EDIT}, tilde, and {ABORT}. If these modules are redefined
- by the text being loaded in, the text load will not work
- properly.
-
- R - renames the local module. Renaming the ROOT module will
- change the name {SAVE} uses when saving the Fifth system.
-
- S - saves the local module and all sub-modules in a format
- suitable for text editors or listing. This format may be
- used in conjunction with the L key to upgrade a Fifth
- program to a higher version number.
-
- T - toggles the trace mode on or off. Trace "ON" allows single
- stepping of Fifth modules. See {TRACE} in the primitives
- section in the manual or use the online help.
-
- X - compiles the local module if nessecary, then strips text from
- the module and all children of the module. This may be used
- to free memory when the module will not need recompiling.
-
-
- -- The Text Editor --
-
- The text editor is invoked by the module {EDIT} or from the local
- dictionary editor, {DIR}. Upon exiting the editor, the compiler
- is invoked. Thus the Fifth compiler, or any other compiler
- implemented under Fifth, is incremental. Parts of the program are
- compiled separately. This gives fast edit-compile-run turn around.
-
- The Fifth module editor is simple. Only the most basic text
- editing functions are provided. Fifth modules are normally quite
- small, thus a simple editor is normally sufficient. In Fifth the
- program structure is edited using the dictionary editor, thus
- providing block operations on functional boundries.
-
- The system editor is a very simple full screen text editor. The
- following is a summary of the key definitions in the editor.
-
- ARROW right/left - Move the cursor right/left
- one character.
-
- ARROW up/down - Move the cursor up/down
- one line.
-
- PAGE up/down (IBM PC)
- or
- ALT ARROW up/down (TI PC) - page up/down.
-
- CONTROL PAGE up/down (IBM PC)
- or
- SHIFT ARROW up/down (TI PC) - Drag line up/down.
-
- F1 - Insert line.
-
- F9 - Split line.
-
- CONTROL Y and F7 - Delete line.
-
- F8 - Undelete line.
-
- F10 - Merge line.
-
- INS - Toggle insert/replace mode.
- The cursor is half height with
- replace mode, full height with
- insert mode.
-
- CONTROL G and DEL - Delete a character.
-
- TAB - Tab.
-
- SHIFT TAB - Back tab.
-
- CONTROL W - Toggle word wrap.
-
- -- Disk I/O --
-
- Disk I/O is through MSDOS 2.00 extended disk I/O calls. Instead
- of a FCB, a 16 bit file handle uniquely identifies the file. If
- old-style I/O is required, the catch-all module INT allows a DOS
- interupt to be used.
-
- All I/O calls are subject to error, this is indicated by the
- error flag and code. The error code is returned by DOS and may
- be found in a DOS manual.
-