NAME

oadl -calc - the OADL desk calculator

OADL Desk Calculator

The OADL calculator accepts valid OADL input files on its command line. This includes proc definitions, var declarations, #include statements, class statements, and so on. In addition, an expression can be typed using any of the variables, classes, etc. defined to this point. The value of the expression will be printed. Finally, a global variable is automatically declared if you type a statement like "a = 3". In the outer calculator mode, statements need not be terminated by semicolons. However, inside braces, the normal rules regarding semicolons apply.

In addition to the above, the following calculator commands are available:

#help Display a help message
#quit Exits the calculator (as will EOF, typically <ctrl>+D)
#procs opt-ns List the global procs - opt-ns is an optional namespace name or the token * (see below)
#vars opt-ns List the global variables
#consts opt-ns List the global constants
#classes opt-ns List the global classes
#objects opt-ns List the global named objects
#intrinsics opt-ns List the intrinsics
#publics List the public indexes
#publics * List the public indexes, including the predefined OADL publics
#externs opt-ns List the extern procedures
#defines List the defined macro names
#namespaces List the defined namespaces
#erase names Erase the named variables, procs, etc.
#save "f.oax" Save a binary for later use by #load or by oadlx
#load "f.oax" Restore a binary produced by #save or by oadlc
#reset Resets the calculator to the initial state; clears everything
#list val Prints the listing of a procedure, class, or other value
#edit val Calls the editor to edit the given procedure, class, or value.

In each case where opt-ns is accepted, the token * can be given instead, which will also include the predefined OADL global values of the given kind in the listing.

Note that errors are not fatal; the OADL machine soft-resets after every statement.

Full documentation of the OADL language may be found at http://rcunniff.com/OADL/oadl.html. Sample OADL test programs may be found at http://rcunniff.com/OADL/Tests/index.html and at http://rcunniff.com/OADL/ADV/index.html.

PREDEFINED VARIABLES

The OADL desk calculator has three predefined calculator-specific global variables, all in namespace oadl:

CalcPrompt1:String The prompt to be used at the outer syntactic scope
CalcPrompt2:String The prompt to be used at a nested syntactic scope
Editor:String The editor to be used for #edit. If unspecified, then default oadledit editor is used.

Since these variables have type String, any values that are assigned to them must be convertable to a String type. The default value for both prompts is four spaces "\x20\x20\x20\x20". This example changes the prompt to make it more obvious when a multi-line value is being created:

    oadl::CalcPrompt1 = "oadl> "
oadl> oadl::CalcPrompt2 = ">>>>> "
oadl> proc fact(n)
>>>>> {
>>>>>     return (n < 2) ? 1 : (n * fact(n-1));
>>>>> }
oadl> fact(3)
6

oadl> a = [
>>>>>      [1,2,3],
>>>>>      [4,5,6]
>>>>> ]
oadl> a
1 2 3
4 5 6

oadl>

EXAMPLES

    // Initially, there are no user variables defined
    #vars
    // However, the namespace "oadl" has a few
    #vars oadl
ArgVec      CalcPrompt1 CalcPrompt2 Editor IterOptim TermColumns TermRows TypePromote
    // Define a variable
    a = 3
    #vars
a
    a
3

    // Erase the variable a
    #erase a
    a
Undefined name a

ENVIRONMENT

The OADL desk calculator reads $HOME/.oadlrc.oad (or %LOCALAPPDATA%\oadlrc.oad on Windows-based systems) at startup; this OADL file can include any valid OADL calculator statements. Typically, this file may contain "#include" statements for OADL system libraries, and a statement overriding the OADL type promotion system; for example, the following .oadlrc.oad file includes the standard OADL library and specifies that arithmetic expressions should have their operands promoted to Double:

#include "libstd"
oadl::TypePromote = Double

The following enviornment variables are used by oadl:

OADL_INC
Semicolon-separated list of directories to be searched for #include files
OADL_SYS
Semicolon-separated list of directories to be searched for OADL system dynamic link libraries
OADL_LIB
Semicolon-separated list of directories to be searched for .oax files specified via the -l option
PATH
System path; used to find and restart OADL if requested
HOME
User's home directory; used to find the OADL startup file .oadlrc.oad
EDITOR
Default editor for #edit (if oadl::Editor is not defined)

SEE ALSO

oadl
oadledit
oadlc
oadlx
oadldb