summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Replacing acons_new_l and aconsq_new_l interfaces with onesKaz Kylheku2014-02-146-24/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | that return the new or old cons cell rather than a pointer to its cdr field. * eval.c (transform_op): use of acons_new_l replaced with acons_new_c. * hash.c (struct hash): acons_new_l_fun member replaced with acons_new_c_fun. (make_hash, make_similar_hash): initialize acons_new_l_fun member using either acons_new_c or aconsql_new_c. (gethash_l): function becomes an inline in hash.h. (gethash_c): new function, based on gethash_l. (inhash, gethash_n): updated w.r.t struct hash change. * hash.h (gethash_c): declared. (gethash_l): becomes an inline wrapper for gethash_c. * lib.c (acons_new_l, aconsql_new_l): functions removed. (acons_new_c, aconsql_new_c): new functions. (obj_init): use gethash_c and rplacd instead of gethash_l and set. * lib.h (acons_new_l, aconsql_new_l): declarations removed. (acons_new_c, aconsql_new_c): declared.
* * hash.c (inhash): Simplify code with gethash_f.Kaz Kylheku2014-02-142-3/+6
|
* * eval.c (eval_init): Registered hash_update_1 as intrinsic.Kaz Kylheku2014-02-145-1/+57
| | | | | | | | * hash.c (hash_update_1): New function. * hash.h (hash_update_1): Declared. * txr.1: Documented hash-update-1.
* * hash.c (inhash): Rename local variable from new to new_p.Kaz Kylheku2014-02-142-3/+9
| | | | | This is consistent with usage elsewhere in the module, and more importantly, keeps our code C++.
* * lib.c (class_check): Bugfix: the function was assuming thatKaz Kylheku2014-02-142-1/+8
| | | | | the argument is a pointer type object, leading to a crash if given a fixnum integer or string literal.
* Different approach: optional arguments on hash-isec and hash-uni allowKaz Kylheku2014-02-145-88/+52
| | | | | | | | | | | | | | | | | | | | | for more flexible joining of data from the hash tables. * eval.c (eval_init): Remove hash_guni and hash_gisec. Change registration for hash_uni and hash_isec to three arguments with one optional. * hash.c (hash_uni): Third parameter introduced, join_func. The default behavior changes: in the two argument case, clashing keys prefer the value from hash1 rather than hash2. For this reason, we now iterate over hash2 first, then hash1. (hash_guni): Removed. (hash_isec): Third parameter introduced, join_func. (hash_gisec): Removed. * hash.h (hash_uni, hash_isec): Declarations updated. (hash_guni, hash_gisec): Delarations removed. * txr.1: Documentation updated.
* * eval.c (eval_init): Register hash_guni and hash_gisec as intrinsics.Kaz Kylheku2014-02-145-6/+95
| | | | | | | | | | | * hash.c (hash_guni, hash_gisec): New functions. (hash_isec): Bugfix: since gethash was naively used, keys in hash2 associated with the value nil were erroneously omitted from the intersection. * hash.h (hash_guni, hash_gisec): Declared. * txr.1: Documented new functions.
* * eval.c (eval_init): Register inhash as intrinsic.Kaz Kylheku2014-02-145-0/+73
| | | | | | | | | * hash.c (inhash): New function. * hash.h (inhash): Declared. * txr.1: Documented inhash. Also, added surprisingly missing documentation for gethash!
* * parser.l: Disallow syntax like 1.0a, flagging it asKaz Kylheku2014-02-122-0/+23
| | | | | | | | an invalid floating-point token. The problem is that 1a is allowed, for compatibility with other Lisp dialects (it is a symbol) whereas 1.0a was scanning as 1.0 followed by a, which is inconsistent. Some Lisp dialects embedded dots in symbols, and allow 1.0a as a symbol token. We don't.
* * hash.c (struct hash): New member, equal_fun.Kaz Kylheku2014-02-122-0/+19
| | | | | | | (hash_equal_op): Short circuited logic: whenever we pull identical cells from either hash, we don't have to go through the pending lookaside list. (make_hash, make_similar_hash): Initialize new structure member.
* * hash.c (hash_equal_op, hash_hash_op): New static functions.Kaz Kylheku2014-02-123-14/+139
| | | | | | | (hash_ops): New functions registered in table of operations. * txr.1: Documentation for equal function updated to explain how two hashes are equal.
* Undoing bogus optimization, which can only work when objectsKaz Kylheku2014-02-122-39/+24
| | | | | | | | are treated as immutable. * hash.c (last_equal_key, last_equal_hash): Variables removed. (equal_hash, hash_process_weak): All references to removed variables scrubbed.
* * lib.c (some_satisfy, all_satisfy, none_satisfy): Fix codingKaz Kylheku2014-02-122-3/+8
| | | | mistake from two commits ago leading to a regression.
* * eval.c (eval_init): Register new functions posqual, posql,Kaz Kylheku2014-02-115-0/+149
| | | | | | | | | | posq, pos, and pos_if as intrinsics. * lib.c (posqual, posql, posq, pos, pos_if): New functions. * lib.h (posqual, posql, posq, pos, pos_if): Declared. * txr.1: Documented
* * eval.c (eval_init): Turn a require argument into an optionalKaz Kylheku2014-02-114-7/+22
| | | | | | | | | | one for the functions some, all and none. * lib.c (some_satisfy, all_satisfy, none_satisfy): Add defaulting behavior for pred parameter. * txr.1: Document that the predicate function is optional in calls to some, all and none.
* Version 79txr-79Kaz Kylheku2014-02-115-4/+36
|
* * eval.c (if_fun): Bugfix: forgotten handling of optionalKaz Kylheku2014-02-112-1/+6
| | | | alternative argument.
* * eval.c (subst_vars): Bugfix: results of expressions notKaz Kylheku2014-02-113-9/+34
| | | | | | | | | | | | treated in the same way as variables: lists not stringified, causing expansions with parentheses, and sometimes errors due to unhandled objects. Also, use tostringp instead of format for stringifying objects. stringifying object. Bugfix.k * match.c (subst_vars): Added comment similar to the one in the subst_vars of eval.c. Removed superfluous conversion code where the str variable is already known to be a string.
* * eval.c (apply): Fix regression in dwim operator: not handlingKaz Kylheku2014-02-112-1/+7
| | | | | nil object properly. Since dwim now trivially delegates to apply, apply must recognize nil.
* * combi.c (comb_hash_while_fun, comb_hash_gen_fun, comb_hash): NewKaz Kylheku2014-02-114-7/+61
| | | | | | | | | | | | | static functions. (comb): Support hash tables. * hash.c (print_key_val): When values are nil, print in a more condensed way by omitting the second element. This notation is accepted as input already by the parser. (hash_insert_pair): New function. * txr.1: Description of comb updated to indicate that it works over hashes.
* * arith.c: Remove inclusion of unneeded headers: <limits.h>Kaz Kylheku2014-02-112-3/+5
| | | | and <dirent.h>.
* * Makefile (OBJS): New object file, combi.o.Kaz Kylheku2014-02-118-614/+703
| | | | | | | | | | | | | | | | * dep.mk: Updated. * eval.c: Removed combination and permutation functions; they now reside in combi.c. (generate): Changed from static to external linkage. * eval.h (generate): Declared. * combi.c: New file. * combi.h: New file. * txr.vim: Regenerated.
* * eval.c (rcomb_gen_fun_common): Streamlined implementation.Kaz Kylheku2014-02-102-10/+14
| | | | Got rid of stack that is consed up on each call.
* Relaxed behavior: don't throw errors for impossible permutations,Kaz Kylheku2014-02-103-50/+78
| | | | | | | | | | | | | | | but return an empty list. * eval.c (perm_init_common): Do not throw error; return a nil state if permutation length exceeds sequence length. (perm_vec, perm_list, perm_str): Check for null return from perm_init_common and return empty list. (k_conses): Do not throw error; return empty list. (comb_list_gen_fun): Check for nil value out of k_conses. (comb): For vectors and strings, check length against k and return nil if necessary. For lists, comb_list_gen_fun handles it. * txr.1: Section order rearranged, and updated.
* * eval.c (rcomb_while_fun, rcomb_gen_fun_common,Kaz Kylheku2014-02-103-3/+159
| | | | | | | | rcomb_list_gen_fun, rcomb_list, rcomb_vec_gen_fun, rcomb_vec, rcomb_str_gen_fun, rcomb_str, rcomb): New static functions. (eval_init): Register rcomb as intrinsic. * txr.1: Documented rcomb.
* * eval.c (rperm, perm_str): Just in case, return a mutable emptyKaz Kylheku2014-02-103-2/+172
| | | | | | | | | | string, rather than null_string, which is a literal. (k_conses, comb_while_fun, comb_gen_fun_common, comb_list_gen_fun, comb_list, comb_vec_gen_fun, comb_vec, comb_str_gen_fun, comb_str, comb): New static functions. (eval_init): Registered comb as instrinsic. * txr.1: Documented comb.
* * eval.c (rperm_list, rperm_vec, rperm_str): n variable renamedKaz Kylheku2014-02-095-22/+271
| | | | | | | | | | | | | | | | | | to k, for consistency with rperm. (rperm): Likewise, and the behavior in the k == zero case is changed to return a single empty permutation. (perm_while_fun, perm_index, perm_gen_fun_common, perm_init_common, perm_vec_gen_fill, perm_vec_gen_fun, perm_vec, perm_list_gen_fill, perm_list_gen_fun, perm_list, perm_str_gen_fill, perm_str_gen_fun, perm_str, perm): New static functions. (eval_init): perm registered as intrinsic. * lib.c (vecref_l): Bugfix: allow negative indices, just like vecref. * lib.h (three, four): New macros. * txr.1: Updated documentation for rperm. Documented perm.
* * lib.c (vector, vec_set_length, cat_vec): When the vector sizeKaz Kylheku2014-02-082-4/+26
| | | | overflows the size_t type that is passed to malloc, throw an exception.
* * eval.c (nperm_while_fun, nperm_gen_fun, nperm_list,Kaz Kylheku2014-02-073-0/+141
| | | | | | | | nperm_vec_gen_fun, nperm_vec, nperm_str_gen_fun, nperm_str, nperm): New static functions. (eval_init): nperm registered as intrinsic. * txr.1: Documented nperm function.
* Version 78.txr-78Kaz Kylheku2014-02-066-72/+131
|
* * lib.c (int_str): Regression: handle base argument properly.Kaz Kylheku2014-02-062-1/+5
|
* * hash.c (hash_grow, make_hash, make_similar_hash, copy_hash):Kaz Kylheku2014-02-066-12/+30
| | | | | | | | | | | | | | | Pass second argument to vector. * lib.c (vector): Takes additional argument specifying the value for the slots of the vector. (vector_list, sub_vec): Pass second argument to vector. * lib.h (vector): Declaration updated. * eval.c (eval_init): Register vector as two-argument function with one required arg. * txr.1: Updated.
* * eval.c (op_dwim): Gutted down to just a few lines.Kaz Kylheku2014-02-064-92/+27
| | | | | | | | | | | | Basically the dwim operator is just a Lisp-1 version of the call operator now. It doesn't have to do anything funny with non-function objects, since they are callable. * lib.c (chr_str, chr_str_set, vecref, vecref_l): Replace inappropriate internal assertions with error exceptions. * unwind.h (numeric_assert, range_bug_unless): Unused macros removed.
* * lib.c (generic_funcall): If a cons cell is passed asKaz Kylheku2014-02-053-0/+43
| | | | | | | one argument to a sequence being used as a function, split it into two arguments. This is consistent with the DWIM operator behavior. * txr.1: Document callable objects.
* Allow sequences and hashes to be called as functions.Kaz Kylheku2014-02-054-25/+79
| | | | | | | | | | | | | | | | This is already supported in the DWIM operator. * eval.c (apply): If object isn't a function, gather the arguments into an array and delegate to generic_funcall. * lib.c (generic_funcall): Changed from static to external linkage. Supports sequences and hashes as functions. Error messages fixed not to refer to "funcall". (funcall, funcall1, funcall2, funcall3, funcall4): Do not throw exception if fun is not of FUN type; instead, delegate to generic_funcall. Error messages fixed not to refer to "funcall". * lib.h (generic_function): Declared.
* * arith.c (lognot): Conform to new scheme for defaulting optional args.Kaz Kylheku2014-02-0511-221/+223
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (apply): Unconditionally use colon_k for missing optional args, for intrinsic functions. (eval_intrinsic, rangev, rangev_star, errno_wrap): Conform to new scheme for defaulting optional args. (reg_fun_mark): Function removed. (eval_init): Switch reduce_left and reduce_right back to reg_fun registration. * hash.c (gethash_n): Conform to new scheme for defaulting optional arguments. * lib.c (sub_list, replace_list, remove_if, keep_if, remove_if_lazy, keep_if_lazy, tree_find, count_if, some_satisfy, all_satisfy, none_satisfy, search_str, match_str, match_str_tree, sub_str, replace_str, cat_str, tok_str, intern, rehome_sym, sub_vec, replace_vec, lazy_str, sort, multi_sort, find, find_if, set_diff, obj_print, obj_pprint): Conform to new scheme for defaulting optional arguments. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Remove references to removed mark_missing_args member of struct func. (func_set_mark_missing): Function removed. (generic_funcall): Unconditionally use colon_k for missing optional args, for intrinsic functions. * lib.h (struct func): mark_missing_args member removed. (func_set_mark_missing): Declaration removed. (default_arg, default_bool_arg): New inline functions. * rand.c (random): Left argument is not optional. (rnd): Conform to new scheme for defaulting optional arguments. * regex.c (search_regex, match_regex): Conform to new scheme for defaulting optional arguments. * stream.c (unget_char, unget_byte, put_string, put_char, put_byte, put_line): Conform to new scheme for defaulting optional arguments. * syslog.c (openlog_wrap): Conform to new scheme for defaulting optional arguments. * txr.1: Remove the specification that nil is a sentinel value in default arguments, where necessary. Use consistent syntax for specifying variable parts in argument lists. A few errors and omissions addressed.
* * eval.c (bind_args): Support optional parameters in theKaz Kylheku2014-02-053-16/+75
| | | | | | | | form (sym initform present-p-sym). Also, support the convention that a value of : explicitly passed for an optional argument produces the same behavior as if that argument value were missing. * txr.1: Document new conventions.
* * eval.c (apply): Pass missing optional arguments as colon_k.Kaz Kylheku2014-02-055-24/+107
| | | | | | | | | | | | | | | | | | | | | | | to functions for which this is requested. (reg_fun_mark): New static function. (eval_init): Register reduce_left and reduce_right as requiring marking for missing optionals. * lib.c (func_set_mark_missing): New function. (generic_funcall): Pass missing optional arguments as colon_k to functions for which this is requested. (reduce_left, reduce_right): Handle missing values of init and key. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Initialize new mark_missing_args member of struct func. * lib.h (struct func): New bitfield member, mark_missing_args. (func_set_mark_missing): Declared. (missingp, null_or_missing_p): New inline functions. * txr.1: Updated descriptions of reduce-left and reduce-right.
* * lib.c (nullp): Function removed.Kaz Kylheku2014-02-033-7/+10
| | | | | * lib.h (nullp): New inline function. (eq): Removed useless parentheses: it's not a macro.
* * eval.c (op_modplace): Fixing a few argument count mismatchesKaz Kylheku2014-02-032-2/+7
| | | | in format calls.
* Tighten up environment visibility semantics of default argumentKaz Kylheku2014-02-033-23/+26
| | | | | | | | | | | | | | | init forms, while streamlining the implementation. * eval.c (bind_args): Get rid of opt_init_parm array hack; turns out we already have a useful function for extending an environment object, namely env_vbind: hitherto unused! We now make a blank environment upfront and extend it destructively with env_vbind. Except that after evaluating an init form, we create a new environment: this is in case a lexical closure was made by the init form, in which event we don't want to be destructively manipulating the environment any more. * txr.1: Clarified.
* * eval.c (eval_init): Fix incorrect registration ofKaz Kylheku2014-02-032-1/+6
| | | | list_star_intrinsic, diagnosed by compiler.
* * txr.1: Mention that regular expression character classes haveKaz Kylheku2014-02-021-0/+2
| | | | no locale-dependent silliness.
* Adding list* since we get it "for free" thanks to theKaz Kylheku2014-02-023-0/+52
| | | | | | | | | new helper function that supports apply. * eval.c (list_star_intrinsic): New static function. (eval_init): Register list_star_intrinsic as list*. * txr.1: Document list*.
* append can now take additional leading arguments before the list.Kaz Kylheku2014-02-025-21/+64
| | | | | | | | | | | | | * eval.c (apply_frob_args): New static function. (apply_intrinsic): Process arguments with apply_frob_args. (eval_init): apply_intrinsic registered differently, as a variadic function with one mandatory arg. * lib.c (lastcons): New function. * lib.h (lastcons): Declared. * txr.1: Updated append documentation.
* * txr.1: Clarify that arbitrary expressions cannot be usedKaz Kylheku2014-02-021-3/+11
| | | | in the dot position of a function call form.
* * eval.c (apply): Support string and vector arglist.Kaz Kylheku2014-02-025-13/+55
| | | | | | | | | | | (do_eval_args): Support string or vector in dot position. * lib.c (tolist): New function. * lib.h (tolist): Declared. * txr.1: Document how apply and dot position in compound forms supports strings as well as vectors.
* * eval.c (do_eval_args): If the dotted position of the argumentKaz Kylheku2014-02-023-4/+75
| | | | | | | list evaluates to a vector, then convert the vector to a list. * txr.1: Document compound forms, and how they allow the dotted position and how it may be a vector.
* * eval.c (eval_init): Register vector_list function a second timeKaz Kylheku2014-02-023-0/+20
| | | | | | under the name vec, as a variadic function. * txr.1: Document vec.
* * txr.1: Fix bad directives example. Regexes are prefixed by #.Kaz Kylheku2014-02-021-1/+1
|