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)))
|
||||
(loop (cddr l)
|
||||
(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
|
||||
(cons (cons (car l) (car ids))
|
||||
kw-pairs))]
|
||||
|
|
|
@ -4,8 +4,12 @@
|
|||
(#%provide syntax-local-infer-name)
|
||||
|
||||
(define (syntax-local-infer-name stx)
|
||||
(or (syntax-property stx 'inferred-name)
|
||||
(let ([n (syntax-local-name)])
|
||||
(let-values ([(prop) (syntax-property stx 'inferred-name)])
|
||||
(or (and prop
|
||||
(not (void? prop))
|
||||
prop)
|
||||
(let ([n (and (not (void? prop))
|
||||
(syntax-local-name))])
|
||||
(or n
|
||||
(let ([s (syntax-source stx)])
|
||||
(and s
|
||||
|
@ -22,4 +26,4 @@
|
|||
(if l
|
||||
(string->symbol (format "~a:~a:~a" s l c))
|
||||
(let ([p (syntax-position stx)])
|
||||
(string->symbol (format "~a::~a" s p))))))))))))
|
||||
(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
|
||||
property value is used for naming the expression, and it overrides any
|
||||
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
|
||||
available, a name is constructed using the source location
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
Similar to @scheme[syntax-local-name] except that @scheme[stx] is
|
||||
checked for an @scheme['inferred-name] property (which overrides any
|
||||
inferred name). If neither @scheme[syntax-local-name] nor
|
||||
@scheme['inferred-name] produce a name, then a name is constructed
|
||||
from the source-location information in @scheme[stx], if any. If no
|
||||
name can be constructed, the result is @scheme[#f].}
|
||||
@scheme['inferred-name] produce a name, or if the
|
||||
@scheme['inferred-name] property value is @|void-const|, then a name
|
||||
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
|
||||
and permission-setting mode
|
||||
racket/file: add user-read-bit, etc.
|
||||
Added special treatment of void as an 'inferred-name property
|
||||
|
||||
Version 5.1.0.2
|
||||
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);
|
||||
if (name && SCHEME_SYMBOLP(name)) {
|
||||
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 {
|
||||
name = rec[drec].value_name;
|
||||
if (!name || SCHEME_FALSEP(name)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user