From e7523b22158785bcd542f2abfe3a3e0d96b7b1ab Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 30 Oct 2016 16:54:19 -0700 Subject: 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. --- lib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib.h') diff --git a/lib.h b/lib.h index 30d4bd5c..8bc72fd4 100644 --- a/lib.h +++ b/lib.h @@ -962,7 +962,7 @@ val empty(val seq); val sub(val seq, val from, val to); val ref(val seq, val ind); val refset(val seq, val ind, val newval); -val dwim_set(val seq, val ind_range, val newval); +val dwim_set(val seq, varg); val dwim_del(val seq, val ind_range); val butlast(val seq, val idx); val replace(val seq, val items, val from, val to); -- cgit v1.2.3