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. --- eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 30ecbb99..d6a52f86 100644 --- a/eval.c +++ b/eval.c @@ -5347,7 +5347,7 @@ void eval_init(void) reg_fun(intern(lit("ref"), user_package), func_n2(ref)); reg_fun(intern(lit("refset"), user_package), func_n3(refset)); reg_fun(intern(lit("replace"), user_package), func_n4o(replace, 2)); - reg_fun(intern(lit("dwim-set"), system_package), func_n3(dwim_set)); + reg_fun(intern(lit("dwim-set"), system_package), func_n1v(dwim_set)); reg_fun(intern(lit("dwim-del"), system_package), func_n2(dwim_del)); reg_fun(intern(lit("update"), user_package), func_n2(update)); reg_fun(intern(lit("search"), user_package), func_n4o(search, 2)); -- cgit v1.2.3