W3C

XEXPR - A Scripting Language for XML

W3C Note 21 November 2000

This Version:
http://www.w3.org/TR/2000/NOTE-xexpr-20001121
Latest version:
http://www.w3.org/TR/xexpr
Editors:
Gavin Thomas Nicol, Chief Scientist, eBusiness Technologies, Inc.

Abstract

In many applications of XML, there is a requirement for using XML in conjunction with a scripting language. Many times, this results in a scripting language such as JavaScript being bound within the XML content (like the <script> tag). XEXPR is a scripting language that uses XML as its primary syntax, making it easily embeddable in an XML document. In addition, XEXPR takes a functional approach, and hence maps well onto the syntax of XML.

Status of This Document

This document is one component of a submission request to the World Wide Web Consortium from eBusiness Technologies, Inc. (see Submission Request, W3C Staff Comment). For a full list of all acknowledged Submissions, please see Acknowledged Submissions to W3C.

This document is a Note made available by W3C for discussion only. This work does not imply endorsement by, or the consensus of the W3C membership, nor that W3C has, is, or will be allocating any resources to the issues addressed by the Note. This document is a work in progress and may be updated, replaced, or rendered obsolete by other documents at any time.

This document is submitted to the W3C in the hope that it will serve an educational and advisory role for future efforts. It is hoped that future effort requiring an XML-based syntax for expressions will use XEXPR.

Should any changes be required to the document, we would expect future versions to be produced by the W3C process. eBT maintains ownership of the XEXPR specification and reserves the right to maintain and evolve the XEXPR specification independently and such independent maintenance and evolution shall be owned by eBT.

A list of current W3C technical documents can be found at the Technical Reports page.


Table of Contents


XEXPR Grammar

The grammar for the XEPR language - a deliberate pun on SEXPR, is defined below. The grammar cannot be expressed completely in a DTD, because DTDs assume a fixed vocabulary (fixed set of tags), and the XEXPR language allows arbitrary definitions (arbitrary tag definitions) to occur. From a practical perspective this means that a document with arbitrary XEXPRs embedded within it cannot be validated against a DTD unless the DTD is extended to include definitions of all the tags found in the expressions in the document.

This is the grammar defined in pseudo-BNF.

function  : '<' id bindings '>' constants '</' id '>'
          ;

bindings  : id "=" "\"" value "\""
          : id "=" "\'" value "\'"
          ;

id        : [a-zA-Z\-\.]+
          ;

value     : string 
          | number 
          ;

constants : constant
          | constants constant
          ;

constant  : function
          | string
          | number
          ;

number    : 0x[0-9A-Fa-f]+
          | [0-9]+
          | [0-9]+.[0-9]+
          | [0-9]+.[0-9]+[+-][eE][0-9]+
          ;

The language is very close to a typical LISP or combinator-based language where the primary means of programming is through functional composition. The only real exception is the bindings construct.

The bindings construct

The bindings construct is designed to make XEXPR somewhat more naturally expressed in XML. It allows attributes to be used as a form of named parameter. In XEPR attributes are a shorthand form of a <define> function. For example, the following two expressions are equivalent.

<email to="authors@ebt.com">hello</email>

<email>
  <define name="to">authors@ebt.com</define>
  hello
</email>

In this case, the <email> function is expecting a value called to to be bound to a value in it's environment, which is what the <define> function does.

Note that <define> is a special case because

<define name="ebt">eBusiness Technologies</define>

cannot be fully decomposed.

Precedence is given to expressions over bindings as the expressions are evaluated as part of the evaluation of the function, and hence override the binding in the environment. For example, the following would print 3, not 2.

<print x="2"><define name="x">3</define><x/></print>

Parsing of PCDATA

The grammar above is somewhat ambiguous in that the constant construct, when PCDATA is encountered, has ill-defined semantics. For example, the following is ambiguous.

<foo>This is the 0xdeadbeef constant.</foo>

The ambiguity lies in whether there is a single string constant, or multiple constants (strings and numbers). Likewise, how many objects form the constant construct in the following example?

<foo>This is a <constant>constant</constant>.</foo>

In the XEXPR language, PCDATA is fully parsed. This means that in the first example, 3 objects match the constant construct. Shown graphically, the parse tree would look like the following.

Parse tree

Parse tree for "<foo>This is the 0xdeadbeef constant.</foo>"

The second example would be similar, with the <constant> function forming a sub-tree of it's own.

Insignificant Whitespace

In addition, XEPXR has a notion of insignificant whitespace. In XEXPR, all whitespace following a start tag is ignored, up to the first non-whitespace character. In addition, all whitespace following a non-whitespace character, up to the end tag, is ignored.

<foo>
   This is a test.
</foo> 

This example would result in the following parse tree.

Parse tree

Resulting parse tree

Note that the leading and trailing whitespace are not part of the constant.

This of course begs the question of how one defines a string with leading and trailing whitespace. The answer is to use the <string> function.

The <string> function

The <string> function serves two roles. Firstly, it acts as a typical combinatorial constant function. Secondly it acts as a signal to the XEXPR parser to pass on the content verbatim. For example, the following expression

<foo>
<string>
    abc
    def
</string>
</foo>

will result in the following parse tree

Parse tree

Parse tree using <string>

which is quite different from the parse tree shown earlier.

Note that the content of a <string> function is still PCDATA, so elements will be parsed as elements, causing errors: the content of <string> must be a sequence of characters.

Function Definition and Invocation

XEXPR allows functions to be defined and invoked in a way somewhat different from both traditional procedural languages and LISP systems. When the <define> function is invoked, the result is a function, in much the same way that lambda works in LISP. The following expressions all result in functions.

<define name="pi">3.14</define>

<define name="2pi">
   <multiply><pi/>2</multiply>
</define>

<define name="square" args="x">
  <multiply><get>x</get> 2</multiply>
</define>

The first returns a function, which returns the numeric constant 3.14. The second returns a function that returns the value of <pi/> multiplied by 2. The last returns a function with a required argument x. If this last one is invoked without arguments, an error will occur. Note that bound arguments such as the above can be accessed either through the <get> function, or directly. The following two definitions are equivalent.

<define name="square" args="x">
  <multiply><get>x</get><get name="x"/></multiply>
</define>

<define name="square" args="x">
  <multiply><x/><x/></multiply>
</define>

Function invocation is fairly traditional. Essentially, all tags get turned into function calls, and the content into arguments. For example

<email><string>gtn@ebt.com</string></email>

invokes the email function with a single argument. If the function definition requires arguments, the arguments are evaluated and bound to the names of the corresponding argument in the argument list. For example

<square>2</square>

calls the square function defined earlier with the argument (numeric constant 2) bound to the x variable in the environment.

Unbound arguments are evaluated, just as bound arguments are, and hence can have side-effects. For example

<square>2<define name="x">4</define></square>

will not evaluate to 4, but instead 16, because the x variable bound in the environment is given a different value by the define call in the argument list. The set function could just as easily been used.

Recursion

An XEXPR interpreter is not guaranteed to be safely tail recursive, even though recursion is allowed. As such, it is generally better to use an iterative form rather than a tail recursive form.

The following defines the linear recursive form of factorial. This is simple to code, and easy to understand, but for large numbers, it may cause a stack overflow.

<define name="factorial" args="x">
 <if>
   <lt><x/>2</lt>
   <x/>
   <multiply>
     <x/>
     <factorial><subtract><x/>1</subtract></factorial>
   </multiply>
 </if>
</define>

The following is the linear iterative form of the same algorithm. While it accomplishes the same thing as the above, it uses far less stack.

<define name="factorial" args="x">
  <define name="iterator" args="product counter max">
    <if>
      <gt><counter/><max/></gt>
      <product/>
      <iterator>
        <multiply><counter/><product/></multiply>
        <add><counter/>1</add>
        <max/>
      </iterator>
    </if>
  </define>

  <iterator>1 1 <x/></iterator>
</define>

This is obviously more complex than the simple recursive form.

Standard Functions

Language features

This section documents the functions that form elements of the XEXPR language or syntax. These functions typically have side effects.

Function <define>

Synopsis

<define> generates a function with the body given by the value provided, and binds it to the name given. If an args parameter is supplied, the function is required to have enough arguments to bind all the names when it is invoked.

Arguments

<define> requires a name argument, and may also have an args argument that supplies a list of names for arguments.

Return Values

A function object is returned.

Example

<define name="pi">3.14</define>

<define name="times2" args="x">
  <multiply><get name="x"/>2</multiply>
</define>

<pi/> --> <float>3.14</float>

<times2>10</times2> -->  <integer>20</integer>

<times2>
  2
  <set name="x">4</set>
</times2> --> <integer>8</integer>

<times2>
  2
<define name="x">5</define>
</times2> --> <integer>10</integer>

Function <print>

Synopsis

<print> is a function that prints its evaluated argument list to standard output.

Arguments

This function takes zero or more expressions as arguments. If the newline attribute has the value true, a newline will also be printed.

Return Values

<true>

Example

<print><add>2 2</add></print>
<print>Hello World</print>
<print newline="true"/>

Function <println/>

Synopsis

<println> is a function that prints a new line to standard output.

Arguments

No arguments are necessary or used.

Return Values

<true>

Example

<println/>

Function <get>

Synopsis

Get the value of a variable from the environment.

Arguments

<get> takes a name argument. It will first look in the environment to see if a name variable has been specified. If a name variable does not exist, it uses the first argument as the name. Note that in most cases; <get> is superfluous because the same effect can be accomplished by using a tag with the name of the value.

Return Values

<get> will return an object. If an object with the given name doesn't exist, <nil/> is returned.

Example

<get name="x"/>
<get>x</get>
<x/>

Function <set>

Synopsis

<set> binds a name to a value in the current environment. If a variable of the given name is not found in the environment, a new variable is created. Note that the difference between <set> and <define> is that <set> evaluates it's arguments, whereas <define> does not.

Arguments

<set> takes a name and a value argument. These can be any combination of named and unnamed arguments. <set> looks first for variables bound to those names, and if they don't exist, uses the first two passed arguments.

Return Values

The value passed is returned.

Example

<set name="x" value="hello"/> -->  <string>hello</hello>
<set name="x">hello</hello> --> <string>hello</string>
<set>hello 123</set> -->  <integer>123</integer>

Function <expr>

Synopsis

<expr> is a function that acts as a grouping mechanism for expressions. In many ways, it is similar to lambda in LISP.

Arguments

This function can take an arbitrary list of arguments, which will then comprise the body of the function. If none are supplied, <nil/> is provided as a body.

Return Values

<expr> returns the evaluated form of the last expression in the function body. If no function body is provided as arguments, the return result is <nil/>.

Example

<expr>
  <set name="x"gt;3</set>
  <print><x/></print>
</expr>

Function <return>

Synopsis

This function is used to signal early exit from a function. It is provided solely to provide a little syntactic sugar for structuring function definitions.

Arguments

<return> takes an arbitrary set of expressions as arguments.

Return Values

<return> returns the evaluated value of the last argument passed to it. If no arguments were supplied, it will return <nil/>.

Example

<define name="foo">
  <return>bar</return>
</define>

Constant functions

This section documents the constant functions. Constant functions are provided as a way to bind constants to a function. In addition, the content of the constant functions is limited to the valid syntactic structures of the constant type.

Function <string>

Synopsis

<string> is used to mark a given expression as a string. No markup can occur within it. The primary intent of this function is to provide an escape from the normal PCDATA parsing rules of XEXPR.

Arguments

<string> takes a string as an argument.

Return Values

This function returns a string constant.

Example

<string>This is #1</string>

Function <integer>

Synopsis

The <integer> function evaluates to an integer constant.

Arguments

This function takes a number as an argument. If the argument is not a number, an exception is thrown.

Return Values

This function returns an integer constant.

Example

<integer>123</integer>

Function <float>

Synopsis

The <float> function evaluates to a floating point constant.

Arguments

This function takes an integer or floating point constant as an argument. If the argument is not a number, an exception is thrown.

Return Values

This function returns a floating point constant.

Example

<float>123</float>
<float>123.143</float>

Function <true/>

Synopsis

<true/> acts both as a self-evaluating function and a constant. It represents the Boolean truth-value.

Arguments

No arguments are required or used.

Return Values

<true/>

Example

<true/>

Function <false/>

Synopsis

<false/> acts both as a self-evaluating function and a constant. It represents the Boolean false-value.

Arguments

No arguments are required or used.

Return Values

<false/>

Example

<false/>

Function <nil/>

Synopsis

<nil/> represents an empty expression. It acts both as a function and as a constant. Note that for Boolean tests, <nil/> and <false/> are equivalent, but when compared directly using <eq/> they are considered different objects.

Arguments

No arguments are required or used.

Return Values

<nil/>

Example

<nil/>

Arithmetic Operators

This section defines the standard arithmetic operators provided by the XEXPR language.

Function <add>

Synopsis

Add a list of arguments together.

Arguments

<add> takes an arbitrary sequence of expressions. All arguments are fully evaluated.

Return Values

The return result is dependent upon the first argument supplied. If it is a string, the return result is a string representation of all the arguments concatenated together. If the first argument is numeric, the result is also numeric provided that all arguments are also numeric. It is an error for a leading numeric argument to be followed by anything other than numeric arguments.

Example

<add>1 2 3</add> -->  <integer>6</integer>
<add>1 2 3.0></add> --> <float>6.0</float>
<add>Hello World#<add>2 2</add></add> --> Hello Word#4
<add><set>x 3</set>2</add> -->  <integer>5</integer>

Function <subtract>

Synopsis

Subtract a list of numbers from the initial number. The first value is taken as the starting point and then subsequent numbers are subtracted from it.

Arguments

<subtract> takes an arbitrary set of expressions as arguments. All arguments are fully evaluated. If any of the evaluated arguments do not result in a numeric constant, an error occurs.

Return Values

<subtract> returns a numeric constant.

Example

<subtract>10 2 1</subtract> -->  <integer>7</integer>

Function <multiply>

Synopsis

Multiply a list of numbers. The first value is taken as the starting point and it is then multiplied by subsequent arguments.

Arguments

<multiply> takes an arbitrary set of expressions as arguments. All arguments are fully evaluated. If the evaluated arguments do not result in a numeric constant, and error occurs.

Return Values

<multiply> returns a numeric constant.

Example

<multipy>10 2 1</multiply> -->  <integer>20</integer>

Function <divide>

Synopsis

Divide a list of numbers. The first value is taken as the starting point and it is then divided by subsequent arguments.

Arguments

<divide> takes an arbitrary set of expressions as arguments. All arguments are fully evaluated. If the evaluated arguments do not result in a numeric constant, and error occurs.

Return Values

<divide> returns a numeric constant.

Example

<divide>20 2 2</divide> -->  <integer>5</integer>

Comparison Functions

This section describes the comparison functions available in the XEXPR language.

Function <eq>

Synopsis

Test a sequence of arguments for equality. Equality means that the evaluated values have the same type and the same value, not the same identity.

Arguments

<eq> takes a sequence of expressions to be tested.

Return Values

<true/> or <false/>

Example

<eq>
  <string>A</string>
  A
  <set name="x">A</set>
</eq> --> <true/>

<eq>
  1 1 1
  <define name="x">1</define>
</eq> --> <true/>

<eq>
  <string>A</string>
  A
  <define name="x">B</define>
</eq> --> <false/>

<eq>
  1 1 1
  <define name="x">2</define>
</eq> --> <false/>

Function <neq>

Synopsis

Check a sequence of expressions for inequality.

Arguments

<neq> takes a sequence of expressions to be tested.

Return Values

<true/> or <false/>

Example

<neq>
  <string>A</string>
  B
  <define name="x">C</define>
</neq> --> <true/>

<neq>
  1 2 3
  <define name="x">4</define>
</neq> --> <true/>

<neq>
  <string>A</string>
  B
  <define name="x">B</define>
</neq> --> <false/>

<neq>
  1 1 2
  <define name="x">2</define>
</neq> --> <false/>

Function <leq>

Synopsis

Evaluate a list of expressions and test if they are sequentially less than or equal to one another. The arguments must all evaluate to the same type of object otherwise <false/> is returned.

Arguments

<leq> takes a sequence of expressions to be tested.

Return Values

<true/> or <false/>

Example

<leq>
  <string>C</string>
  B
  <define name="x">B</define>
</leq> --> <true/>

<leq>
  4 3 2 1
  <define name="x">1</define>
</leq> --> <true/>

<leq>
  <string>C</string>
  B
  <define name="x">C</define>
</leq> --> <false/>

<leq>
  4 3 2 1
  <define name="x">2</define>
</leq> --> <false/>

Function <geq>

Synopsis

Evaluate a list of expressions and test if they are sequentially greater than or equal to one another. The arguments must all evaluate to the same type of object otherwise <false/> is returned.

Arguments

<geq> takes a sequence of expressions to be tested.

Return Values

<true/> or <false/>

Example

<geq>
  <string>A</string>
  B
  <define name="x">B</define>
</geq> --> <true/>

<geq>
  1 2 3
  <define name="x">3</define>
</geq> --> <true/>

<geq>
  <string>A</string>
  B
  <define name="x">A</define>
</geq> --> <false/>

<geq>
  1 1 2
  <define name="x">1</define>
</geq> --> <false/>

Function <lt>

Synopsis

Evaluate a list of expressions and test if they are sequentially less than one another. The arguments must all evaluate to the same type of object otherwise <false/> is returned.

Arguments

<lt> takes a sequence of expressions to be tested.

Return Values

<true/> or <false/>

Example

<lt>
  <string>A</string>
  B
  <define name="x">C</define>
</lt> --> <true/>

<lt>
  1 2 3
  <define name="x">4</define>
</lt> --> <true/>

<lt>
  <string>A</string>
  B
  <define name="x">B</define>
</lt> --> <false/>

<lt>
  1 2 3
  <define name="x">3</define>
</lt> --> <false/>

Function <gt>

Synopsis

Evaluate a list of expressions and test if they are sequentially greater than one another. The arguments must all evaluate to the same type of object otherwise <false/> is returned.

Arguments

<gt> takes a sequence of expressions to be tested.

Return Values

<true/> or <false/>

Example

<gt>
  <string>C</string>
  B
  <define name="x">A</define>
</gt> --> <true/>

<gt>
  4 3 2
  <define name="x">1</define>
</gt> --> <true/>

<gt>
  <string>C</string>
  B
  <define name="x">C</define>
</gt> --> <false/>

<gt>
  4 3 2
  <define name="x">3</define>
</gt> --> <false/>

Logic Operators

Function <and>

Synopsis

<and> sequentially evaluates its arguments. If all evaluate to <true/> it returns <true/> otherwise it will return <false/>. Arguments that evaluate to anything other than <true/> result in <false/> being returned, including arguments of anything other than Boolean type. Note that this is a logical, not a bitwise and.

Arguments

<and> can take an arbitrary list of arguments.

Return Values

<and> returns <true/> or <false/> depending on the arguments supplied. If no arguments are supplied, <and> returns <true/>.

Example

<and>
  <true/>
  <define name="x"><true/></define>
</and> --> <true/>

<and>
  <true/>
  <define name="x"><false/></define>
</and> --> <false/>

Function <or>

Synopsis

<or> evaluates its arguments sequentially. If any are <true/> it returns <true/> otherwise <false/>. Note that this is a logical or, not a bitwise or.

Arguments

<or> can take an arbitrary list of arguments.

Return Values

<or> returns <true/> or <false/> depending on the arguments supplied. If no arguments are supplied, <or> returns <true/>.

Example

<or>
  <true/>
  <define name="x"><true/></define>
</or> --> <true/>

<or>
  <true/>
  <define name="x"><false/></define>
</or> --> <true/>

<or>
  <false/>
  <define name="x"><false/></define>
</or> --> </false>

Function <not>

Synopsis

<not> evaluates its arguments sequentially. If any are <false/> it returns <true/> otherwise <false/>. Note that this is a logical not, not a bitwise not.

Arguments

<not> can take an arbitrary list of arguments.

Return Values

<not> returns <true/> or <false/> depending on the arguments supplied. If no arguments are supplied, <not> returns <true/>.

Example

<not><true/></not> --> <false/>
<not><false/></not> --> <true/>
<not><nil/></not> --> <true/>
<not>1</not> --> <false/>

Conditionals

Function <if>

Synopsis

<if> represents a conditional branching of program flow.

Arguments

<if> requires at least 2 arguments to be passed: the test and the expression to evaluate if the test evaluates to <true/>. This is roughly akin to an if-then logic flow. <if> can also take a 3rd argument which is the expression to evaluate if the test evaluates to <false/>, in which case, the if expression is equivalent to an if-then-else statement.

Return Values

<if> returns the evaluated result of the expression selected by the test. If the test fails and only 2 arguments are supplied, <if> will return <nil/>.

Example

<if>
  <eq>1 2</eq>
  <expr>
     <print>equal</print>
  </expr>
  <expr>
     <print>not equal</print>
  </expr>
</if>

Function <switch>

Synopsis

<switch> is similar to <if> but represents a multi-way branch.

Arguments

<switch> requires a list of <case> expressions. Each <case> expression in turn must be made up of a test expression, and an expression to evaluate if the test is evaluated to <true/>.

Return Values

Each of the tests in the <case> expressions is evaluated in turn. The first test that evaluates to <true/> decides the result of the <switch>, which is the evaluated result of the expression part of the <case> expression. If none evaluate to <true/>, <nil/> is returned.

Example

<define name="test1" args="x">
  <switch>
    <case>
      <eq><x/>1</eq>
      1
    </case>
    <case>
      <true/>
      2
    </case>
  </switch>
</define>

<define name="test2" args="x">
  <switch>
    <case>
      <eq><x/>1</eq>
      1
    </case>
  </switch>
</define>

<test1>1</test1> --> <integer>1</integer>
<test1>2</test1> --> <integer>2</integer>
<test2>1</test2> --> <integer>1</integer>
<test2>2</test2> --> <nil/>

Looping Constructs

This section documents the looping constructs XEXPR provides. Note that in addition to these, linear iterative forms can be used to form loops.

Function <while>

Synopsis

<while> loops over a given expression so long as the supplied test evaluates to <true/></>

Arguments

<while> takes two arguments. The first is the test expression, the second is the expression to be executed so long as the test evaluates to <true/>.

Return Values

<while> returns the value of the last evaluated expression.

Example

<while>
  <gt><x/> 0</gt>
  <expr>
    <print newline="true"><x/><print>
    <subtract><x/> 1</subtract>
  </expr>
</while>

Function <do>

Synopsis

<do> loops over a given expression so long as the supplied test evaluates to <true/>. It will execute the body at least once.

Arguments

<do> takes two arguments. The first is the body to be executed, the second is the expression to be tested.

Return Values

<do> returns the value of the last evaluated expression.

Example

<do>
  <expr>
    <print newline="true"><x/><print>
    <subtract><x/> 1</subtract>
  </expr>
  <gt><x/> 0</gt>
</do>

Complete DTD

Namespace

The namespace URI for XEXPR is

http://www.ebt.com/xexpr

People using this namespace are encouraged to use the xexpr namespace prefix.

Public Identifier

The public identifier for XEXPR is

-//EBT//DTD XML Expression Language//EN

Definitions

<!DOCTYPE xexpr [
<!ENTITY % expression "bind|define|get|set
                       |expr|add|subtract|multiply
                       |divide|string|integer|float
                       |true|false|nil|eq|neq|leq
                       |geq|lt|gt|and|or|not|if
                       |switch|do|while|print
                       |println">

<!ELEMENT xexpr (%expression;)*>

<!ELEMENT bind EMPTY>
<!ATTLIST bind class CDATA #REQUIRED
               name  CDATA #IMPLIED>


<!ELEMENT define (%expression;)*>
<!ATTLIST define name CDATA #REQUIRED
                 args CDATA #IMPLIED>


<!ELEMENT get EMPTY>
<!ATTLIST get name CDATA #REQUIRED>


<!ELEMENT set (%expression;)*>
<!ATTLIST set name CDATA #REQUIRED>


<!ELEMENT expr (%expression;)*>


<!ELEMENT add (%expression;)*>
<!ELEMENT subtract (%expression;)*>
<!ELEMENT multiply (%expression;)*>
<!ELEMENT divide (%expression;)*>
<!ELEMENT string (#PCDATA)>
<!ELEMENT integer (#PCDATA)>
<!ELEMENT float (#PCDATA) >
<!ELEMENT true EMPTY>
<!ELEMENT false EMPTY>
<!ELEMENT nil EMPTY>
<!ELEMENT eq (%expression;)*>
<!ELEMENT neq (%expression;)*>
<!ELEMENT leq (%expression;)*>
<!ELEMENT geq (%expression;)*>
<!ELEMENT lt (%expression;)*>
<!ELEMENT gt (%expression;)*>
<!ELEMENT and (%expression;)*>
<!ELEMENT or (%expression;)*>
<!ELEMENT not (%expression;)*>
<!ELEMENT if (%expression;)*>
<!ELEMENT switch   (case*) >
<!ELEMENT case (%expression;)*>
<!ELEMENT do (%expression;)*>
<!ELEMENT while (%expression;)*>
<!ELEMENT print (#PCDATA|%expression;)*>
<!ATTLIST print newline (true|false) #IMPLIED>
<!ELEMENT println (#PCDATA|%expression;)*>
]>

Glossary

actual parameter
A parameter given when routine is called.
algorithm
A definition of the steps needed to carry out a computation.
applicative
A functional and strict (not lazy) evaluation style.
atom
The smallest (indivisible) part of a program.
bind
To fix ab object/expression to a name.
bound variable
An expression that is bound to a name.
closure
A point in a computation including the environment.
combinator
A function that does not access variables outside it's own local scope (parameters and local variables)
conditional
Statements like "if then else"
declarative
A form of program based on declarations of fact.
dereference
To get the value of a bound variable.
environment
A collection of bound variables. The environment changes as the program executes.
expression
A way fo computing a value. Typically a set of statements.
functional
A forms of programming without assignments.
Lisp
LISt Processing language
name parameter
An actual parameter that is reevaluated each time the parameter is dereferenced.
predicate
A function that evaluates to true or false.
recursion
See recursion
reduction
One step in the complete evaluation of an expression.
scope
The area in the program that the expression appears in. The environment is affected by the scope.
side-effect
The result of an expression changing things in an unexpected way.

Bibliography

The following is a list of recommended reading.

Structure and Interpretation of Computer Programs
Harold Abelson and Gerald Jay Sussman
Object Oriented System Development
Dennis de Chapeaux, Douglas Lea, Penelope Faure
XML 1.0
http://www.w3.org/XML