diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-10-16 07:50:36 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-10-16 07:50:36 -0700 |
commit | 8c907a932436a8bdc2c52d2a28e14115df525654 (patch) | |
tree | e7260805bbff9835999340820255ac98ae64686f /tree.c | |
parent | bdc7277d09377f87319e0c27de40210b0212fabc (diff) | |
download | txr-8c907a932436a8bdc2c52d2a28e14115df525654.tar.gz txr-8c907a932436a8bdc2c52d2a28e14115df525654.tar.bz2 txr-8c907a932436a8bdc2c52d2a28e14115df525654.zip |
tree: printing: handle unnamed functions.
* tree.c (tree): If the tree abstraction functions don't have
a name, then use the functions themselves as the names, rather
than nil. Otherwise the printed representation of the tree
will look like it has the default abstraction functions.
Diffstat (limited to 'tree.c')
-rw-r--r-- | tree.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -596,14 +596,18 @@ val tree(val keys_in, val key_fn, val less_fn, val equal_fn) val keys = default_null_arg(keys_in), key; val tree = cobj(coerce(mem_t *, tr), tree_s, &tree_ops); seq_iter_t ki; + uses_or2; tr->key_fn = default_null_arg(key_fn); tr->less_fn = default_null_arg(less_fn); tr->equal_fn = default_null_arg(equal_fn); - tr->key_fn_name = if2(tr->key_fn, func_get_name(tr->key_fn, nil)); - tr->less_fn_name = if2(tr->less_fn, func_get_name(tr->less_fn, nil)); - tr->equal_fn_name = if2(tr->equal_fn, func_get_name(tr->equal_fn, nil)); + tr->key_fn_name = if2(tr->key_fn, + or2(func_get_name(tr->key_fn, nil), tr->key_fn)); + tr->less_fn_name = if2(tr->less_fn, + or2(func_get_name(tr->less_fn, nil), tr->key_fn)); + tr->equal_fn_name = if2(tr->equal_fn, + or2(func_get_name(tr->equal_fn, nil), tr->key_fn)); seq_iter_init(tree_s, &ki, keys); |