Objects and Forms: an Overview

Mathscript is a language that accomplishes almost everything it does by means of Commands, Programs, and Functions. These are the verbs of the language and they all operate on objects, which are the nouns of the language.

In Mathscript, as in ordinary mathematical discourse, it is possible to think of mathematical functions both as verbs and as nouns. In simple terms, one might, in one context, use a mathematical function to transform something, and might, in another context, apply transformations to mathematical functions themselves. For example, one might add, or compose functions.

Now commands, programs, and functions all have this in common: They accept
arguments. In any simple function statement such as: sin(x+pi/2), the "x+pi/2" is the actual argument. In a simple command statement such as: graph sin+cos-f, the sin+cos-f is the actual argument. See Mathscript Syntax and Conventions for a discussion of syntax. Here, we make a few general observations about how Mathscript interprets such statements.

When Mathscript reads a statement like sin(x+pi/2) it
evaluates the actual argument x+pi/2, then proceeds to apply the sin to value[x+pi/2]. The scheme is similar for commands and programs.

When Mathscript sees a command, program, or function statement:

It
evaluates the actual arguments supplied in the statement, returning an ordered list of values: value[ arg1], value[ arg2], ..., value[ argn]. It applies the function, program, or command to that list of values. In the case of functions and programs, it returns the value of the application. In the case of commands, it does not return a value.

Now this notion of
evaluation is very important, so we say a few things about it.

The value of a number or a string is the number or string itself.

The value of an unassigned variable is the variable itself

The value of an assigned variable is whatever the variable was assigned to.

E.g. after make x 3, value[x] = 3.

The value of a program or function statement is the application of the program or function to the list of values of its actual arguments.

Binary operators such as +, -, *, / , ^, and #, are applied to the values of their operands. The value of an algebraic expression is the result of this application.

The items in the language which are evaluated, the nouns, become upon evaluation the

actual arguments to commands, programs and functions. These will be called forms. An

important property of a form is that it always has a
type. The value of a form is a

mathematical object. And the type determines what sort of object it is.