diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-10-30 16:54:19 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-10-30 16:54:19 -0700 |
commit | e7523b22158785bcd542f2abfe3a3e0d96b7b1ab (patch) | |
tree | 9bafdb4d9020d89bf69702c5205ab11a570ae616 /args.h | |
parent | adef4143af67eb8874e7013eb2c0b40da2099e5b (diff) | |
download | txr-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.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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); |