On this page:
^<d
^>d
^<
^>
8.2

5 Baseline Punctaffy Hyperbracket Notations

 (require punctaffy) package: punctaffy-lib

Punctaffy is a framework for macros to have access to higher-dimensional structure in the code they operate on. Just as parentheses give more structure to 1-dimensional text streams to create s-expressions (or Racket syntax objects), hyperbrackets can give more structure to Racket syntax objects to create infinite-dimensional higher-order nesting structure.

Most programs will use only a few of the lower dimensions. For instance, quasiquotation is an operation that works with a 2-dimensional snippet (what we call a hypersnippet) of literal code and several 1-dimensional expressions that will be interpolated into it. All it takes is a 3-dimensional syntactic medium to represent any number of nested and juxtaposed 2-dimensional quasiquotation operations, just as all it takes is a 2-dimensional syntactic medium (s-expressions) to represent any nesting or juxtaposition of 1-dimensional function calls.

Punctaffy’s notation represents an infinite-dimensional syntactic medium. The goal of Punctaffy is to assist in defining higher-dimensional operations that play nicely with each other by building common tools and notations for them to build on. Punctaffy’s notation generalizes far enough to be a common medium for notations of arbitrarily high dimension.

Punctaffy’s main module, punctaffy, provides the hyperbracket notation itself, which just about every higher-dimensional macro built on Punctaffy will use.

Whether a certain notation uses Punctaffy’s hyperbrackets or not, if it has a straightforward analogue as an operaton that uses hyperbrackets, we call it a hyperbracketed operation. We refer to code where hyperbrackets can appear as hyperbracketed code.

syntax

(^<d degree term ...)

A hyperbracket notation that represents an opening hyperbracket with a specified nonzero degree. The degree must be a natural number literal.

Using this notation as an expression is a syntax error. In the future, this error may be replaced with #%app-like functionality.

When writing a hyperbracket parser, this notation can be recognized using hyperbracket-open-with-degree?.

For the common case where degree is 2, see the shorthand ^<, which has examples in Introduction to Punctaffy. For a rare example of hypothetical code where degree would be 3, see Potential Application: Interactions Between unsyntax and Ellipses.

syntax

(^>d degree term ...)

A hyperbracket notation that represents a closing hyperbracket with a specified nonzero degree. The degree must be a natural number literal.

This notation is not an expression. Using it as an expression is a syntax error.

When writing a hyperbracket parser, this notation can be recognized using hyperbracket-close-with-degree?.

For the common case where degree is 1, see the shorthand ^>, which has examples in Introduction to Punctaffy. For a rare example of hypothetical code where degree would be 2, see Potential Application: Interactions Between unsyntax and Ellipses.

syntax

(^< term ...)

A hyperbracket notation shorthand that specifically represents an opening hyperbracket of degree 2. This is the lowest, and hence the most likely to be commonplace, degree of opening bracket that isn’t already easy to represent in Racket’s syntax.

This represents the same thing as (^<d 2 term ...).

Note that while ^< involves a degree of 2, ^> involves a degree of 1. This may seem confusing out of context, but these two often match up with each other.

Using this notation as an expression is a syntax error. In the future, this error may be replaced with #%app-like functionality.

For examples of how to use ^< and ^>, see Introduction to Punctaffy.

syntax

(^> term ...)

A hyperbracket notation shorthand that specifically represents a closing hyperbracket of degree 1. This is the lowest, and hence the most likely to be commonplace, degree of closing bracket that isn’t already easy to represent in Racket’s syntax.

This represents the same thing as (^>d 1 term ...).

Note that while ^> involves a degree of 1, ^< involves a degree of 2. This may seem confusing out of context, but these two often match up with each other.

This notation is not an expression. Using it as an expression is a syntax error.

For examples of how to use ^< and ^>, see Introduction to Punctaffy.