summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-12 13:01:35 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-12 13:01:35 -0700
commit80e54b31220f4fdc414d793ff97bbfb127c1d4a1 (patch)
tree68197cf039e426a0d9f5c1d20305893d168e5ad9 /lib.h
parentff18ec7c29456025f7e4e29c4d24f5efa1913ca8 (diff)
downloadtxr-80e54b31220f4fdc414d793ff97bbfb127c1d4a1.tar.gz
txr-80e54b31220f4fdc414d793ff97bbfb127c1d4a1.tar.bz2
txr-80e54b31220f4fdc414d793ff97bbfb127c1d4a1.zip
* eval.c (merge_wrap): New static function
(eval_init): Register less as intrinsic. Retarget merge intrinsic to merge_wrap for proper argument defaulting which is missing from merge, and which we don't want to introduce there since internal calls to merge don't erquire it. Change registration of sort so it has only one required argument, not two. * lib.c (less_f): New global variable. (less_tab): New static array. (less_tab_init): New static function. (less): New function. (sort): Default lessfun argument to the less function. (obj_init): GC-protect the less_f variable. Initialize it with a function object made from the less function. (init): Call less_tab_init. * lib.h (enum type): New enumeration member MAX_TYPE, an alias for the largest type. (less_f, less): Declared. * txr.1: Documented new less function, and that the lessfun argument in sort and merge is optional, defaulting to less. * txr.vim: Regenerated.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib.h b/lib.h
index f9fdf904..bb58669c 100644
--- a/lib.h
+++ b/lib.h
@@ -42,7 +42,8 @@ typedef int_ptr_t cnum;
typedef enum type {
NIL, NUM = TAG_NUM, CHR = TAG_CHR, LIT = TAG_LIT, CONS,
STR, SYM, PKG, FUN, VEC, LCONS, LSTR, COBJ, ENV,
- BGNUM, FLNUM /* If extending, check TYPE_SHIFT */
+ BGNUM, FLNUM, MAXTYPE = FLNUM
+ /* If extending, check TYPE_SHIFT */
} type_t;
#define TYPE_SHIFT 4
@@ -378,7 +379,7 @@ extern val null_string;
extern val null_list; /* (nil) */
extern val identity_f, equal_f, eql_f, eq_f, gt_f, lt_f, car_f, cdr_f, null_f;
-extern val list_f;
+extern val list_f, less_f;
extern const wchar_t *progname;
extern val prog_string;
@@ -599,6 +600,7 @@ val flo_str(val str);
val num_str(val str);
val int_flo(val f);
val flo_int(val i);
+val less(val left, val right);
val chrp(val chr);
wchar_t c_chr(val chr);
val chr_isalnum(val ch);