7 Source Locations
There are two libraries in this collection for dealing with source locations;
one for manipulating representations of them, and the other for quoting the
location of a particular piece of source code.
This module defines utilities for manipulating representations of source
locations, including both srcloc structures and all the values accepted
by datum->syntax’s third argument: syntax objects, lists, vectors, and
These functions recognize valid source location representations. The first,
, recognizes srcloc
objects, lists, and vectors with appropriate structure, as well as #f
The latter predicates recognize only valid lists and vectors, respectively.
This procedure checks that its input is a valid source location. If it is, the
procedure returns (void)
. If it is not,
raises a detailed error message in terms of
and the problem with x
These procedures combine multiple (zero or more) source locations, merging
locations within the same source and reporting #f
for locations that
span sources. They also convert the result to the desired representation:
, list, vector, or syntax object, respectively.
This predicate reports whether a given source location contains more information
than simply #f.
These accessors extract the fields of a source location.
This accessor produces the end position of a source location (the sum of its
position and span, if both are numbers) or #f.
Produces a modified version of loc, replacing its fields with
source, line, column, position, and/or
span, if given.
These procedures convert source locations to strings for use in error messages.
The first produces a string describing the source location; the second appends
": " to the string if it is non-empty.
This module defines macros that evaluate to various aspects of their own source
Note: The examples below illustrate the use of these macros and the
representation of their output. However, due to the mechanism by which they are
generated, each example is considered a single character and thus does not have
realistic line, column, and character positions.
Furthermore, the examples illustrate the use of source location quoting inside
macros, and the difference between quoting the source location of the macro
definition itself and quoting the source location of the macro’s arguments.
Quotes the source location of form
as a srcloc
structure, using the location of the whole (quote-srcloc)
expression if no expr
is given. Uses relative directories
for paths found within the collections tree, the user’s collections directory,
or the PLaneT cache.
Quote various fields of the source location of form, or of
the whole macro application if no form is given.
'(eval 2 0 2 1)
'(eval 3 0 3 1)
'(eval 3 0 3 1)
'(eval 7 0 7 1)
'(eval 8 0 8 1)
Quotes the name of the module in which the form is compiled as a path or symbol,
when used outside of a module. To produce a name
suitable for use in printed messages, apply
when the result is a path.
This form is deprecated, as it does not produce module paths that reliably
indicate collections or PLaneT packages. Please use quote-module-name
and path->relative-string/library to produce human-readable module
names in printed messages.
Quotes the name of the module in which the form is compiled as a
module path using quote or file,
or produces 'top-level when used outside of a module.