[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 2.7.4.2 Semantics

Declarations in `silly` should be understood in the obvious way as preprocessor directives to perform parenthetic textual substitutions (similar to `#define id (exp)` in C). All identifiers in expressions are thereby eliminated during the preprocessing phase.

The overall meaning of the program is the meaning of the expression in the last declaration. A denotational semantics for expressions is given by the following equations, where [[`x`]] should be read as “the meaning of `x`”, and `x`, `y` and `z` are metavariables. (That is, they stand for any source code fragment that could fit there subject to the constraint, informally speaking, that it has to correspond to a connected subtree of the parse tree as enforced by the unambiguous grammar in the context of the rest of the program.)

    [[()]] = nil

    [[(x)]] = [[x]]

    [[(x,y)]] = cons([[x]],[[y]])

    [[x y]] = [[x(y)]] = [[x]] [[y]]

    [[x (y,z)]] = [[x(y,z)]] = [[x]] [[(y,z)]]

Toy languages like this are among the few situations a denotational semantics stands a chance of clarifying more than it obfuscates, so the reader is invited to take a moment to savor it.

[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

This document was generated on November 8, 2012 using texi2html 1.82.