From 424696dc09a91939c8c5fb66975be0f737fac9aa Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Apr 2016 19:57:38 -0700 Subject: Fix proper-listp to proper-list-p. This is really a gratuitous incompatibility with Common Lisp and other dialects. Let's fix it internally also, but keep the proper-listp function binding for backwards compatibility. * eval.c (dot_to_apply, me_op): Update proper_listp call to proper_list_p. (eval_init): Register proper-list-p to the same C function as proper-listp, and that C function is now called proper_list_p. * lib.c (proper_listp): Renamed to proper_list_p. * lib.h (proper_listp): Declaration updated. * parser.y (define_transform): Update proper_listp call. * txr.1: Replace all occurrences of proper-listp with proper-list-p. Add note explaining the rename situation. --- eval.c | 10 +++++++--- lib.c | 2 +- lib.h | 2 +- parser.y | 2 +- txr.1 | 23 +++++++++++++++++------ 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/eval.c b/eval.c index daa795ba..25678510 100644 --- a/eval.c +++ b/eval.c @@ -2498,7 +2498,7 @@ static val imp_list_to_list(val list) static val dot_to_apply(val form, val lisp1_p) { - if ((opt_compat && opt_compat <= 137) || proper_listp(form)) { + if ((opt_compat && opt_compat <= 137) || proper_list_p(form)) { return form; } else { val sym = car(form); @@ -2937,7 +2937,7 @@ static val me_op(val form, val menv) uses_or2; val dwim_body = rlcp_tree(cons(dwim_s, if3(or4(is_op, has_rest, ssyms, - null(proper_listp(body_trans))), + null(proper_list_p(body_trans))), body_trans, append2(body_trans, rest_gensym))), body_trans); @@ -4789,7 +4789,11 @@ void eval_init(void) reg_fun(intern(lit("consp"), user_package), func_n1(consp)); reg_fun(intern(lit("lconsp"), user_package), func_n1(lconsp)); reg_fun(intern(lit("listp"), user_package), func_n1(listp)); - reg_fun(intern(lit("proper-listp"), user_package), func_n1(proper_listp)); + { + val proper_list_p_f = func_n1(proper_list_p); + reg_fun(intern(lit("proper-listp"), user_package), proper_list_p_f); + reg_fun(intern(lit("proper-list-p"), user_package), proper_list_p_f); + } reg_fun(intern(lit("length-list"), user_package), func_n1(length_list)); reg_fun(intern(lit("mapcar"), user_package), func_n1v(mapcarv)); diff --git a/lib.c b/lib.c index 2e5091dd..b827c705 100644 --- a/lib.c +++ b/lib.c @@ -2571,7 +2571,7 @@ val listp(val obj) return if2(obj == nil || consp(obj), t); } -val proper_listp(val obj) +val proper_list_p(val obj) { while (consp(obj)) obj = cdr(obj); diff --git a/lib.h b/lib.h index 92e08352..51d51fc6 100644 --- a/lib.h +++ b/lib.h @@ -584,7 +584,7 @@ val consp(val obj); val lconsp(val obj); val atom(val obj); val listp(val obj); -val proper_listp(val obj); +val proper_list_p(val obj); val length_list(val list); val getplist(val list, val key); val getplist_f(val list, val key, loc found); diff --git a/parser.y b/parser.y index e4a1552e..5b5f7105 100644 --- a/parser.y +++ b/parser.y @@ -1346,7 +1346,7 @@ static val define_transform(parser_t *parser, val define_form) return define_form; } - if (!proper_listp(params)) { + if (!proper_list_p(params)) { yyerr("invalid function parameter list"); return define_form; } diff --git a/txr.1 b/txr.1 index a211b1e2..b833f54f 100644 --- a/txr.1 +++ b/txr.1 @@ -15370,16 +15370,16 @@ For a description of the arguments, semantics and return value, refer to the .code replace function. -.coNP Functions @ listp and @ proper-listp +.coNP Functions @ listp and @ proper-list-p .synb .mets (listp << value ) -.mets (proper-listp << value ) +.mets (proper-list-p << value ) .syne .desc The .code listp and -.code proper-listp +.code proper-list-p functions test, respectively, whether .meta value is a list, or a proper list, and return @@ -15400,7 +15400,7 @@ The empty list is a list, and a cons cell is a list. The -.code proper-listp +.code proper-list-p function returns .code t only for proper lists. A proper list is @@ -15409,10 +15409,21 @@ either or a cons whose .code cdr is a proper list. -.code proper-listp +.code proper-list-p traverses the list, and its execution will not terminate if the list is circular. +Dialect Note: in \*(TX 137 and older, +.code proper-list-p +is called +.codn proper-listp . +The name was changed for adherence to conventions and compatibility with other +Lisp dialects, like Common Lisp. However, the function continues to be +available under the old name. Code that must run on \*(TX 137 and older +installations should use +.codn proper-listp , +but its use going forward is deprecated. + .coNP Function @ length-list .synb .mets (length-list << list ) @@ -40318,7 +40329,7 @@ substring matches. For instance is a possible completion for .codn list , as is -.codn proper-listp . +.codn proper-list-p . If no completions are found, then the BEL character is sent to the terminal to generate a beep or a visual alert indication. The listener returns to -- cgit v1.2.3