special treatment of void as 'inferred-name property
allows keyword-based application to hide temporary names that happen to be bound to procedure arguments
This commit is contained in:
parent
3fb4561a62
commit
cf69cb2aff
|
@ -821,7 +821,11 @@
|
||||||
[(keyword? (syntax-e (car l)))
|
[(keyword? (syntax-e (car l)))
|
||||||
(loop (cddr l)
|
(loop (cddr l)
|
||||||
(cdr ids)
|
(cdr ids)
|
||||||
(cons (list (car ids) (cadr l)) bind-accum)
|
(cons (list (car ids) (syntax-property (cadr l)
|
||||||
|
'inferred-name
|
||||||
|
;; void hides binding name
|
||||||
|
(void)))
|
||||||
|
bind-accum)
|
||||||
arg-accum
|
arg-accum
|
||||||
(cons (cons (car l) (car ids))
|
(cons (cons (car l) (car ids))
|
||||||
kw-pairs))]
|
kw-pairs))]
|
||||||
|
|
|
@ -4,22 +4,26 @@
|
||||||
(#%provide syntax-local-infer-name)
|
(#%provide syntax-local-infer-name)
|
||||||
|
|
||||||
(define (syntax-local-infer-name stx)
|
(define (syntax-local-infer-name stx)
|
||||||
(or (syntax-property stx 'inferred-name)
|
(let-values ([(prop) (syntax-property stx 'inferred-name)])
|
||||||
(let ([n (syntax-local-name)])
|
(or (and prop
|
||||||
(or n
|
(not (void? prop))
|
||||||
(let ([s (syntax-source stx)])
|
prop)
|
||||||
(and s
|
(let ([n (and (not (void? prop))
|
||||||
(let ([s (let ([s (format
|
(syntax-local-name))])
|
||||||
"~a"
|
(or n
|
||||||
(cond
|
(let ([s (syntax-source stx)])
|
||||||
[(path? s) (path->string s)]
|
(and s
|
||||||
[else s]))])
|
(let ([s (let ([s (format
|
||||||
(if ((string-length s) . > . 20)
|
"~a"
|
||||||
(string-append "..." (substring s (- (string-length s) 20)))
|
(cond
|
||||||
s))]
|
[(path? s) (path->string s)]
|
||||||
[l (syntax-line stx)]
|
[else s]))])
|
||||||
[c (syntax-column stx)])
|
(if ((string-length s) . > . 20)
|
||||||
(if l
|
(string-append "..." (substring s (- (string-length s) 20)))
|
||||||
(string->symbol (format "~a:~a:~a" s l c))
|
s))]
|
||||||
(let ([p (syntax-position stx)])
|
[l (syntax-line stx)]
|
||||||
(string->symbol (format "~a::~a" s p))))))))))))
|
[c (syntax-column stx)])
|
||||||
|
(if l
|
||||||
|
(string->symbol (format "~a:~a:~a" s l c))
|
||||||
|
(let ([p (syntax-position stx)])
|
||||||
|
(string->symbol (format "~a::~a" s p)))))))))))))
|
||||||
|
|
|
@ -968,7 +968,10 @@ When an @indexed-racket['inferred-name] property is attached to a
|
||||||
syntax object for an expression (see @secref["stxprops"]), the
|
syntax object for an expression (see @secref["stxprops"]), the
|
||||||
property value is used for naming the expression, and it overrides any
|
property value is used for naming the expression, and it overrides any
|
||||||
name that was inferred from the expression's context. Normally, the
|
name that was inferred from the expression's context. Normally, the
|
||||||
property value should be a symbol or an identifier.
|
property value should be a symbol. A @racket['inferred-name]
|
||||||
|
property value of @|void-const| hides a name that would otherwise be
|
||||||
|
inferred from context (perhaps because a binding identifier's was
|
||||||
|
automatically generated and should not be exposed).
|
||||||
|
|
||||||
When an inferred name is not available, but a source location is
|
When an inferred name is not available, but a source location is
|
||||||
available, a name is constructed using the source location
|
available, a name is constructed using the source location
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
Similar to @scheme[syntax-local-name] except that @scheme[stx] is
|
Similar to @scheme[syntax-local-name] except that @scheme[stx] is
|
||||||
checked for an @scheme['inferred-name] property (which overrides any
|
checked for an @scheme['inferred-name] property (which overrides any
|
||||||
inferred name). If neither @scheme[syntax-local-name] nor
|
inferred name). If neither @scheme[syntax-local-name] nor
|
||||||
@scheme['inferred-name] produce a name, then a name is constructed
|
@scheme['inferred-name] produce a name, or if the
|
||||||
from the source-location information in @scheme[stx], if any. If no
|
@scheme['inferred-name] property value is @|void-const|, then a name
|
||||||
name can be constructed, the result is @scheme[#f].}
|
is constructed from the source-location information in @scheme[stx],
|
||||||
|
if any. If no name can be constructed, the result is @scheme[#f].}
|
||||||
|
|
|
@ -2,6 +2,7 @@ Version 5.1.0.4
|
||||||
Change file-or-directory-permission to add 'bits mode
|
Change file-or-directory-permission to add 'bits mode
|
||||||
and permission-setting mode
|
and permission-setting mode
|
||||||
racket/file: add user-read-bit, etc.
|
racket/file: add user-read-bit, etc.
|
||||||
|
Added special treatment of void as an 'inferred-name property
|
||||||
|
|
||||||
Version 5.1.0.2
|
Version 5.1.0.2
|
||||||
Enabled single-precision floats by default
|
Enabled single-precision floats by default
|
||||||
|
|
|
@ -1944,6 +1944,10 @@ Scheme_Object *scheme_build_closure_name(Scheme_Object *code, Scheme_Compile_Inf
|
||||||
name = scheme_stx_property(code, scheme_inferred_name_symbol, NULL);
|
name = scheme_stx_property(code, scheme_inferred_name_symbol, NULL);
|
||||||
if (name && SCHEME_SYMBOLP(name)) {
|
if (name && SCHEME_SYMBOLP(name)) {
|
||||||
name = combine_name_with_srcloc(name, code, 0);
|
name = combine_name_with_srcloc(name, code, 0);
|
||||||
|
} else if (name && SCHEME_VOIDP(name)) {
|
||||||
|
name = scheme_source_to_name(code);
|
||||||
|
if (name)
|
||||||
|
name = combine_name_with_srcloc(name, code, 1);
|
||||||
} else {
|
} else {
|
||||||
name = rec[drec].value_name;
|
name = rec[drec].value_name;
|
||||||
if (!name || SCHEME_FALSEP(name)) {
|
if (!name || SCHEME_FALSEP(name)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user