summaryrefslogtreecommitdiffstats
path: root/args.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-10-30 16:54:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-10-30 16:54:19 -0700
commite7523b22158785bcd542f2abfe3a3e0d96b7b1ab (patch)
tree9bafdb4d9020d89bf69702c5205ab11a570ae616 /args.h
parentadef4143af67eb8874e7013eb2c0b40da2099e5b (diff)
downloadtxr-e7523b22158785bcd542f2abfe3a3e0d96b7b1ab.tar.gz
txr-e7523b22158785bcd542f2abfe3a3e0d96b7b1ab.tar.bz2
txr-e7523b22158785bcd542f2abfe3a3e0d96b7b1ab.zip
lambda-set method: treat [struct ...] as place.
* eval.c (eval_init): Change registration of dwim-set to only one required argument, with the rest variadic. * lib.c (lambda_set_s): New symbol variable. (dwim_set): Change to variadic function that takes all arguments other than the object/sequence being operated on as struct args *. Rewrite to do a test on the object type first, handling hashes and structs specially. (obj_init): Initialize lambda_set_s. * share/txr/stdlib/place.tl (defplace dwim): Rewritten for more generic syntax. The only argument required is obj-place; the other arguments are treated as a variable argument list, all treated uniformly. This eliminates the special handling of the default value for hash lookups. * args.h (args_count): New inline function. * txr.1: Updated documentation for dwim operator, which neglects to mention use over objects thanks to the lambda function. Documented lambda-set.
Diffstat (limited to 'args.h')
-rw-r--r--args.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/args.h b/args.h
index 68d301b8..5735b828 100644
--- a/args.h
+++ b/args.h
@@ -181,6 +181,11 @@ INLINE void args_clear(struct args *args)
args->fill = 0;
}
+INLINE cnum args_count(struct args *args)
+{
+ return args->fill + c_num(length_list(args->list));
+}
+
val args_get_checked(val name, struct args *args, cnum *arg_index);
struct args *args_copy(struct args *to, struct args *from);
struct args *args_copy_zap(struct args *to, struct args *from);