28 Syntax utilities
Utilities for creating macros and working with syntax.
Compares two identifiers based on their symbolic representation.
Creates an identifier by appending args. Equivalent to:
where arg->string converts an argument to a string.
Returns a string describing the source location of stx (for example "myfile.ss:123:45").
(begin-for-syntax/any-order definition ...) | ||||||||||
|
Like begin-for-syntax except that definitions can refer to previous definitions in the manner of a letrec statement. Only definitions are allowed within the body of the form.
(dotted-identifier? stx [min-parts max-parts]) → boolean? |
stx : syntax? |
min-parts : (U natural? #f) = 2 |
max-parts : (U natural? #f) = #f |
Returns #f if stx represents an identifier comprised of one or more parts joined by dots. Parts can be zero-length.
The min-parts and max-parts arguments can be used limit the number of allowed parts (both limits are inclusive).
Examples: |
> (dotted-identifier? #'a) |
#f |
> (dotted-identifier? #'.a) |
#t |
> (dotted-identifier? #'a.b) |
#t |
> (dotted-identifier? #'a.) |
#t |
> (dotted-identifier? #'a.b.c 3 3) |
#t |
> (dotted-identifier? #'a 1) |
#t |
| |||||||||||||||||||||
stx : syntax? | |||||||||||||||||||||
min-parts : (U natural? #f) = 2 | |||||||||||||||||||||
max-parts : (U natural? #f) = #f |
Like dotted-identifier? except all parts must be a minimum length of 1.
Examples: |
> (simple-dotted-identifier? #'a) |
#f |
> (simple-dotted-identifier? #'a.b) |
#t |
> (simple-dotted-identifier? #'.a) |
#f |
> (simple-dotted-identifier? #'a.) |
#f |
(dotted-identifier-count dotted-id-stx) → natural? |
dotted-id-stx : identifier? |
Returns the number of parts in dotted-id-stx.
Examples: |
> (dotted-identifier-count #'a) |
1 |
> (dotted-identifier-count #'a.b) |
2 |
> (dotted-identifier-count #'a.b.c) |
3 |
> (dotted-identifier-count #'.a) |
2 |
(dotted-identifier-split dotted-id-stx) → (listof identifier?) |
dotted-id-stx : identifier? |
Splits dotted-id-stx into its constituent parts.
Examples: |
> (map syntax->datum (dotted-identifier-split #'a)) |
(a) |
> (map syntax->datum (dotted-identifier-split #'a.b)) |
(a b) |
> (map syntax->datum (dotted-identifier-split #'a.b.c)) |
(a b c) |
> (map syntax->datum (dotted-identifier-split #'.a)) |
(|| a) |