Syntax

This chapter defines Dyna’s concrete syntax.

Quote vs Eval

Dyna’s syntax has both nested terms (also called recursive terms) and in-place evaluation. (Recall the discussion in Disposition.) Managing the details in a way that is (ideally) not too surprising to users requires some technical complexity.

Since this all takes place at parse time, the most upon which we can really expect to key our decisions is the term’s functor and arity. Each (functor,arity) pair may specify

  • A self disposition, which may be one of evaluate, quote, or inherit. No functors in Dyna (by default) use evaluate; it is offered to facilitate the development of more Prolog-like syntaxes.
  • For each argument, a argument disposition which may be either evaluate or quote.

Additionally, there are two explicit operators defined in the language:

  • A quotation operator, prefix unary &.
  • An evaluation operator, prefix unary *.

When attempting to understand a term in a Dyna program, one must keep track of:

  • The argument disposition of the location where it occurs. Functors specify this as per above; an aggregator will always place its head in a quoted context and its body in an evaluation context.
  • The number of * operators seen between the functor’s argument position and the functor of the inner term.
  • Whether or not the sequence of quotation and evaluation operators ends with a quotation operator. Note that only the right end matters; that is, *&*& has the same effect as **&.
  • The self disposition of the inner functor.

The interpretation is then the first matching row in this table:

Context Eval Operators Quoted? Self Effect
Any 0 Yes Any Quotation (explicit at site)
Any 0 No Quote Quotation (implicit from self)
Any 0 No Evaluate Evaluation (implicit from self)
Quote 0 No Inherit Quotation (implicit from context)
Evaluate 0 No Inherit Evaluation (implicit from context)
Any \(n > 0\) Yes Any \(n\)-chained evaluation
Any \(n > 0\) No Evaluate \((n+1)\)-chained evaluation
Any \(n > 0\) No Any \(n\)-chained evaluation

Where, by “\(n\)-chained evaluation”, we mean one evaluation of the term at hand, and then \(n-1\) indirect evaluations where the value is fed through the chart to obtain the next value. The last of these is taken to be the value of the chain as a whole. See spec-indirect-evaluation for more details.

Project Versions

Table Of Contents

This Page