adjust printing of renamed procedures

When ">" appears in a procedure name, or when other characters appear
that would normally need to be escaped in a symbol, don't add escapes
since `#<....>` isn't readable anyway. This change makes renamed
procedures print in a consistent way with primitive procedures.

Similarly adjust the printing of structure type names.

Closes #2646
This commit is contained in:
Matthew Flatt 2019-05-18 09:51:37 -04:00
parent a56c984db0
commit 7f92443a5f
3 changed files with 10 additions and 8 deletions

View File

@ -144,6 +144,12 @@
(ptest "'(#<procedure:add1>)" (list add1))
(ptest "'#(#<procedure:add1>)" (vector add1))
(ptest "#<procedure:add1>" add1)
(ptest "#<procedure:x->y>" (procedure-rename add1 'x->y))
(ptest "#<procedure:#x,y>" (procedure-rename add1 '|#x,y|))
(let ()
(struct a (x))
(ptest "#<procedure:a->x>" (procedure-rename a-x 'a->x)))
(ptest "(arity-at-least 1)" (arity-at-least 1))

View File

@ -13,8 +13,7 @@
[max-length (write-string/max what o max-length)]
[name-str
(cond
[(symbol? name)
(symbol->print-string name #:for-type? #t)]
[(symbol? name) (symbol->string name)]
[(path? name) ; especially for input & output ports
(path->string name)]
[(string? name)

View File

@ -2333,12 +2333,9 @@ print(Scheme_Object *obj, int notdisplay, int compact, Scheme_Hash_Table *ht,
name = SCHEME_STRUCT_NAME_SYM(obj);
}
s = scheme_symbol_name_and_size(name, (uintptr_t *)&l,
(pp->print_struct
? SCHEME_SNF_FOR_TS
: (pp->can_read_pipe_quote
? SCHEME_SNF_PIPE_QUOTE
: SCHEME_SNF_NO_PIPE_QUOTE)));
s = scheme_symbol_val(name);
l = SCHEME_SYM_LEN(name);
print_utf8_string(pp, s, 0, l);
PRINTADDRESS(pp, obj);
print_utf8_string(pp, ">", 0, 1);