Delimiter-Sensitive Application
1 API Reference
delimit-app
delimit-app-base-app
delimit-app/  paren
delimit-app/  bracket
delimit-app/  brace
2 Integration with fancy-app
delimit-app/  fancy-app
8.12

Delimiter-Sensitive Application🔗ℹ

This library provides a definition of function application (an #%app macro) that changes meaning depending on whether parentheses, brackets, or braces are used. By default parentheses mean normal function application, brackets construct a list, and braces construct a hash. Also included is an optional delimit-app/fancy-app module that provides out-of-the-box integration with fancy-app.

1 API Reference🔗ℹ

 (require delimit-app) package: delimit-app

syntax

(delimit-app v ...)

Performs delimiter-sensitive application. If parentheses are used, expands to (delimit-app/paren v ...). If brackets are used, expands to (delimit-app/bracket v ...). If braces are used, expands to (delimit-app/brace v ...). Each of these forms are syntax parameters that can be customized with syntax-parameterize. The default implementations of these parameters are defined in terms of the syntax parameter delimit-app-base-app, allowing a user to customize the underlying definition of function application irrespective of which delimiters are used. The type of delimiter is determined by analyzing the 'paren-shape syntax property.

Examples:
> (delimit-app + 1 2 3)

6

> [delimit-app + 1 2 3]

'(#<procedure:+> 1 2 3)

> {delimit-app + 1 2 3}

'#hash((2 . 3) (#<procedure:+> . 1))

This identifier is also provided under the name #%app, overriding traditional function application when delimit-app is imported.

Examples:
> (+ 1 2 3)

6

> [+ 1 2 3]

'(#<procedure:+> 1 2 3)

> {+ 1 2 3}

'#hash((2 . 3) (#<procedure:+> . 1))

syntax

(delimit-app-base-app v ...)

A syntax parameter that defines what #%app syntax delimit-app is implemented in terms of. Override this to integrate delimit-app with a form of function application other than the one provided by racket/base. See delimit-app/fancy-app for an example of what overriding this can achieve.

syntax

(delimit-app/paren v ...)

syntax

(delimit-app/bracket v ...)

syntax

(delimit-app/brace v ...)

Syntax parameters that define what delimit-app expands to when used with parentheses, brackets, or braces, respectively. The default definitions are:

When overriding these parameters, be sure to use delimit-app-base-app in function application positions to ensure modules that override that syntax parameter continue to work. Overriding is achieved with syntax-parameterize.

Example:
> (syntax-parameterize ([delimit-app/brace
                         (make-rename-transformer #'delimit-app/paren)])
    (delimit-app/brace + 1 2 3))

6

Note that these forms completely ignore the 'paren-shape syntax property, which is only used by delimit-app to dispatch to the correct syntax parameter.

Example:
> {delimit-app/paren + 1 2 3}

6

2 Integration with fancy-app🔗ℹ

 (require delimit-app/fancy-app) package: delimit-app

syntax

(delimit-app/fancy-app v ...)

Like delimit-app, but where delimit-app-base-app is parameterized to the #%app macro from fancy-app. The fancy-app package defines application that constructs anonymous functions using underscores. Also provided by delimit-app/fancy-app as #%app.

Examples:
> (define make-person {'name _ 'age (random 100)})
> (make-person 'Alice)

'#hash((age . 91) (name . Alice))

> (make-person 'Bob)

'#hash((age . 56) (name . Bob))