summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-21 18:30:13 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-21 18:30:13 -0700
commit47cd15b970892e2dae29e825fadaf31c6d84835d (patch)
treeed34c519095f6cc351d90b91c90887c1c491c9a4 /eval.c
parent969b24f06ad615f56f452c87cf2735b5978c754f (diff)
downloadtxr-47cd15b970892e2dae29e825fadaf31c6d84835d.tar.gz
txr-47cd15b970892e2dae29e825fadaf31c6d84835d.tar.bz2
txr-47cd15b970892e2dae29e825fadaf31c6d84835d.zip
compiler: tighter code for quasiliterals.
Give the sys:fmt-simple function argument defaulting so the generated code doesn't have to call it with all five arguments present, four of them nil being much of the time. * eval.c (fmt_simple): Default all but the first four arguments. (eval_init): Re-register sys:fmt-simple as having only one required argument. * parser.c (read_file_common): Load version 1 or 2 files. We are bumping the object file version to 2 because now when we compile files, they won't work with older TXR in which all five arguments to sys:fmt-simple are required. * share/txr/stdlib/compiler.tl (expand-quasi-mods): Generate the sys:fmt-simple call with just enough arguments to express the modifiers that were decoded. (sexpand-quasi-args): Reduce the trivial modifier-less sys:fmt-simple calls to just one argument. (%tlo-ver%): Bump major version to 2.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index 72f98210..0b374d50 100644
--- a/eval.c
+++ b/eval.c
@@ -2692,12 +2692,15 @@ val format_field(val obj, val modifier, val filter, val eval_fun)
return do_format_field(obj, n, sep, range_ix, plist, filter);
}
-static val fmt_simple(val obj, val n_in, val sep_in,
+static val fmt_simple(val obj, val n, val sep,
val range_ix, val plist)
{
- val n = if3(null(n_in), zero, n_in);
- val sep = if3(null(sep_in), lit(" "), sep_in);
- return do_format_field(fmt_tostring(obj), n, sep, range_ix, plist, nil);
+ return do_format_field(fmt_tostring(obj),
+ default_arg(n, zero),
+ default_arg(sep, lit(" ")),
+ default_null_arg(range_ix),
+ default_null_arg(plist),
+ nil);
}
static val fmt_flex(val obj, val plist, struct args *args)
@@ -6532,7 +6535,7 @@ void eval_init(void)
reg_fun(intern(lit("tprint"), user_package), func_n2o(tprint, 1));
reg_fun(intern(lit("display-width"), user_package), func_n1(display_width));
- reg_fun(intern(lit("fmt-simple"), system_package), func_n5(fmt_simple));
+ reg_fun(intern(lit("fmt-simple"), system_package), func_n5o(fmt_simple, 1));
reg_fun(intern(lit("fmt-flex"), system_package), func_n2v(fmt_flex));
reg_fun(intern(lit("fmt-join"), system_package), func_n0v(fmt_join));