
In #956, @gus-massa warned that `syntax-local-infer-name` was changed in a breaking way, but the implications were not clear. At a minimum, identifiers need to be treated like symbols, so that `mzlib/contract` name inference works right. I'm erroring more generally on the side of keeping the old behavior for anything other than pair-based trees. Closes #1117.
29 lines
1.2 KiB
Racket
29 lines
1.2 KiB
Racket
#lang scribble/doc
|
|
@(require "common.rkt" (for-label syntax/name))
|
|
|
|
@title[#:tag "name"]{Extracting Inferred Names}
|
|
|
|
@defmodule[syntax/name]
|
|
|
|
@defproc[(syntax-local-infer-name [stx syntax?] [use-local? any/c #t]) any/c]{
|
|
|
|
Similar to @racket[syntax-local-name], except that @racket[stx] is
|
|
checked for an @racket['inferred-name] property
|
|
(which overrides any inferred name).
|
|
If neither @racket[syntax-local-name] nor
|
|
@racket['inferred-name] produce a name, or if the
|
|
@racket['inferred-name] property value is @|void-const|, then a name
|
|
is constructed from the source-location information in @racket[stx],
|
|
if any. If no name can be constructed, the result is @racket[#f].
|
|
|
|
To support the propagation and merging of consistent properties during
|
|
expansions, the value of the @racket['inferred-name] property can be a
|
|
tree formed with @racket[cons] where all of the leaves are the same.
|
|
For example, @racket[(cons 'name 'name)] is equivalent to
|
|
@racket['name], and @racket[(cons (void) (void))] is equivalent to
|
|
@|void-const|.
|
|
|
|
If @racket[use-local?] is @racket[#f], then @racket[syntax-local-name] is
|
|
not used. Provide @racket[use-local?] as @racket[#f] to construct a name
|
|
for a syntax object that is not an expression currently being expanded.}
|