summaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
...
* * Makefile, arith.c, arith.h, combi.c, combi.h, configure, debug.c,Kaz Kylheku2014-07-231-16/+16
| | | | | | | | debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Synchronize license header with LICENSE.
* * eval.c (me_case): Fix quoting issue in expansion.Kaz Kylheku2014-07-221-1/+3
|
* * eval.c (caseq_s, caseql_s, casequal_s, memq_s, memql_s, memqual_s,Kaz Kylheku2014-07-201-6/+66
| | | | | | | | | | | eq_s, eql_s, equal_s): New symbol variables. (me_case): New static function. (eval_init): Initialize new variables. Register caseq, caseql and casequal macros. Re-register memq, memql, memqual, eq, eql and equal using new symbol variables. * txr.1: Document case, caseql and casequal.
* * eval.c (eval_init): Register juxt as intrinsic.Kaz Kylheku2014-07-201-0/+1
| | | | | | | | | * lib.c (do_juxt): New static function. (juxtv): New function. * lib.h (juxtv): Declared. * txr.1: Documented juxt.
* * arith.c (divi): Support one-argument form.Kaz Kylheku2014-07-201-1/+1
| | | | | | | | | Use "/" name in error reporting, not "divi". * eval.c (eval_init): Change registration of / so only one argument is required out of two. * txr.1: Document one-argument division.
* * eval.c (mapdov): New function.Kaz Kylheku2014-07-191-0/+25
| | | | | | | | | | | (eval_init): Register mapdo intrinsic. * lib.c (mapdo): New function. * lib.h (mapdo): Declared. * txr.1: Documented mapdo. Documented zero-argument case for mapcar, mapcar*, mappend and mappend*.
* * eval.c (eval_init): Register get-lines as a synonym for lazy-stream-cons.Kaz Kylheku2014-07-191-0/+1
| | | | | | | | | | | * stream.c (get_string): New function. * stream.h (get_string): Declared. (stream_init): get_string registered as get-string intrinsic. * txr.1: Documented get-string, and get-lines as a synonym for lazy-stream-cons. Documented the behavioral difference of lazy-stream-cons lazy lists for real-time and non-real-time streams.
* * Makefile (conftest, conftest2): Link mathKaz Kylheku2014-07-181-0/+1
| | | | | | | | | | | | | | | | | | | library so we can test for math functions. * arith.c (log2_init): New static function. (log2, logtwo): New functions. (l2): New static variable. (arith_init): Call log2_init. * configure (lang_flags): Switching _XOPEN_SOURCE from 500 to 600 to reveal log2. Adding test for log2. * eval.c (eval_init): Register log2 intrinsic. * lib.h (logtwo): Declared. * txr.1: Documented log2.
* * eval.c (eval_init): Register interpose and lconsp as intrinsics.Kaz Kylheku2014-07-141-0/+2
| | | | | | | | | * lib.c (lconsp, interpose): New functions. (lazy_interpose_func, lazy_interpose): New static functions. * lib.h (lconsp, interpose): Declared. * txr.1: Documented lconsp and interpose.
* Implementing local function binding constructs.Kaz Kylheku2014-07-101-3/+118
| | | | | | | | | | | | | | | | * eval.c (fbind_s, lbind_s, flet_s, labels_s): New symbol globals. (env_fb_to_fb): New static function. (lookup_mac): Implement the same shadow check for function macros that is done for symbol macros, because we now have local functions that can shadow local macros. (fbindings_helper, op_fbind, make_fun_shadowing_env, expand_fbind_vars, me_flet_labels): New static functions. (expand): Add cases for fbind and lbind. (eval_init): Intern the four new symbols. Register sys:fbind and sys:lbind operators. Register flet and labels macros. * txr.1: Documented flet and labels.
* * eval.c: Comment spelling.Kaz Kylheku2014-07-101-1/+1
|
* * eval.c (bindings_helper): New parameter to indicate thatKaz Kylheku2014-07-081-6/+9
| | | | | | | | the caller needs the return value, so the function can avoid consing up a list that will be thrown away. (op_let): Pass nil argument to new parameter of bindings_helper. (op_each, op_for): Pass t to indicate that the return value is needed.
* * eval.c (apf_s, ipf_s): New symbol variables.Kaz Kylheku2014-07-031-12/+19
| | | | | | | | | | | | (me_ap, me_ip): Generate a much simpler macro-expansion: a call to apf or ipf, rather than lambda syntax. (me_ado, me_ido): New static functions. (eval_init): Initialize apf_s and ipf_s variables. Use them in the registration calls for apf and ipf. Register ado and ido macros. * txr.1: Streamlined documentation for ap and ip, and added ado and ido.
* * eval.c (apf, ipf): Bugfix: do_apf and do_ipfKaz Kylheku2014-07-031-2/+2
| | | | should be registered as variadic functions.
* * eval.c (dwim_loc): Support indexing using a list of positions,Kaz Kylheku2014-07-021-10/+29
| | | | | | | | | | | | | | | such as obtained by the where function. * lib.c (replace_list, replace_str, replace_vec): Allow the from argument to be a list of index positions, possibly empty. * txr.1: Condensed syntactic descriptions under dwim operator. Range Indexing section no longer says that the value nil can be used as either endpoint of a range. This will not work any longer since a "from" value of nil looks like an empty list of indexes. Documented new behavior under replace, and shortened documentation for replace-list, replace-str and replace-vec.
* * arith.c (bit): New function.Kaz Kylheku2014-06-281-0/+1
| | | | | | | | | | * eval.c (eval_init): Register bit as intrinsic. * lib.h (bit): Declared. * mpi-patches/add-bitops (mp_bit): New function. * txr.1: Documented bit
* Bugfix: apply_intrinsic and iapply must not destructivelyKaz Kylheku2014-06-271-22/+27
| | | | | | | | | | | | manipulate argument lists. * eval.c (apply_frob_args): Rewrite to non-destructive one-pass version. (iapply): Likewise. * lib.c (term): New function. * lib.h (term): Declared.
* * eval.c (iapply_s): new global variable.Kaz Kylheku2014-06-261-2/+49
| | | | | | | | | | (iapply, me_ip): new static functions. (do_apf): Bugfix: use apply_intrinsic, not apply. (do_ipf, ipf): New static functions. (eval_init): initialize iapply_s. register me_ip macro expander, and the iapply and ipf functions. * txr.1: Documented iapply, ipf and ip.
* * eval.c (eval_init): register range_regex and tok_whereKaz Kylheku2014-06-261-0/+2
| | | | | | | | | | | | | | as intrinsics. * lib.c (tok_where): New function. * lib.h (tok_where): Declared. * regex.c (range_regex): New function. * regex.h (range_regex): Declared. * txr.1: Documented tok-where and range-regex.
* * eval.c (mapcarv): Use mapcar_listout, so list_of_lists can beKaz Kylheku2014-06-261-1/+3
| | | | | | | | | | | | | a non-list sequence. (eval_init): Register transpose and zip as intrinsics. * lib.c (curry_12_1_v): New static function. (transpose, mapcar_listout): New functions. (mapcar): Redefined in terms of mapcar_listout. * lib.h (transpose, mapcar_listout): Declared. * txr.1: Documented transpose and zip.
* Bugfix: macros not being expanded in expansions embedded inKaz Kylheku2014-06-201-0/+14
| | | | | | | | | | | | | | quasilierals: i.e. the forms X and Y in `@{X}` and `@{X Y}`, where X and Y can be Lisp symbol macros or compound forms that is a macro call. * eval.c (expand_quasi): Handle the var forms in a quasi. * parser.y (n_exprs_opt, q_var): New grammar nonterminals. q_var is a clone of o_var, but with different construction behavior. It fixes the bug that o_var applies expand_meta to embedded Lisp forms, which is not appropriate for TXR Lisp quasiliterals. (quasi_item): Derive q_var rather than o_var.
* * eval.c (do_apf, apf): New functions.Kaz Kylheku2014-06-201-0/+11
| | | | | | (eval_init): Register apf as intrinsic. * txr.1: Document apf.
* Improve error reporting.Kaz Kylheku2014-06-201-8/+12
| | | | | | | * eval.c (eval_error): Use last_form_evaled if form is null. (apply): Substitute apply symbol if ctx_form is null. (apply_intrinsic): Do not pass fake (apply) context form to apply, just pass nil.
* * eval.c (identity_s): New global variable.Kaz Kylheku2014-06-191-2/+35
| | | | | | | | | (me_ret, tf, nilf, do_retf, retf): New static functions. (eval_init): Initialize identity_s, and use it for registration of identity. Register ret macro, and the retf, tf and nilf functions. * txr.1: Documentation for ret, retf, tf and nilf.
* Bugfix: dwim operator contradicts the documentationKaz Kylheku2014-06-191-1/+1
| | | | | | | | | | and intended design. * eval.c (do_eval): When calling do_eval_args to evaluate the arguments of a compound form that is a function call, do not pass down the lookup function, but substitute &lookup_var. Passing down the lookup function means tha all evaluation enclosed in (dwim ...) or [...] follows the Lisp-1 style.
* * eval.c (me_ap): New static function.Kaz Kylheku2014-06-191-1/+13
| | | | | | | | | | | | | | (eval_init): Use new list_f instead of func_n0v(identity). Register multi as intrinsic. Register me_ap as ap macro. * lib.c (list_f): New global variable. (multi): New function. (multi_sort): Use list_f in place of func_n0v(identity). (obj_init): gc-protect and initialize list_f. * lib.h (list_f, multi): Declared. * txr.1: Documented multi and ap.
* * eval.c (eval_init): Register member and member_if as intrinsics.Kaz Kylheku2014-06-181-0/+2
| | | | | | | | | | * lib.c (member, member_if): New functions. * lib.h (member, member_if): Declared. * txr.1: Documented. * txr.vim: Regenerated.
* * eval.c (not_null): New static function.Kaz Kylheku2014-06-171-2/+9
| | | | | | | | (eval_init): Use null_f in existing registration of null and not. Add registration for not_null as "true", and for null_f as "false". * txr.1: Documented true and false.
* * eval.c (eval_init): register tuples as intrinsic.Kaz Kylheku2014-06-171-0/+1
| | | | | | | | | * lib.c (tuples_func): New static function. (tuples): New function. * lib.h (tuples): Declared. * txr.1: Documented.
* * eval.c (eval_init): Register pos_max, pos_min, find_max,Kaz Kylheku2014-06-151-0/+5
| | | | | | | | | | | | | | | | | | find_min and seqp as intrinsics. * lib.c (gt_f, lt_f): New variables. (to_seq): renamed to toseq. (seqp): New function. (minmax): New static function. (replace_str, replace_vec): Follow to_seq renaming. (find_max, find_min, pos_max, pos_min): New functions. (obj_init): gc-protect and initialize gt_f and lt_f. * lib.h (gt_f, lt_f): Declared. (to_seq): Declaration updated to toseq. (seqp, find_max, find_min, pos_max, pos_min): Declared. * txr.1: Updated.
* * eval.c (eval_init): where and sel registered as intrinsicsKaz Kylheku2014-06-151-0/+2
| | | | | | | | | | | | where and select. * lib.c (generic_funcall): Support a sequence as an argument to a sequence. (where, sel): New functions. * lib.h (where, sel): Declared. * txr.1: Documented.
* Bugfix: range and range* broken when "to" argument isKaz Kylheku2014-06-151-5/+5
| | | | | | | | omitted. This was broken in version 89, by the 2014-04-08 commit. * eval.c (rangev_func, range_star_v_func): Only perform numeric tests between from and to if to is not nil.
* * eval.c (eval_init): Change registration of string_cmpKaz Kylheku2014-06-101-2/+7
| | | | | | | | | | | | | | | | | | | to cmp_str. Add registrations for str_eq, str_lt, str_gt, str_le, and str_lt. * lib.c (string_cmp): Name changes to cmp_str, and the function fixed so that it actually works. The name change doesn't affect anyone because the function was too broken to use due to the incorrect type dispatch. (string_lt): Name changes to str_lt. (str_eq, str_gt, str_le, str_ge): New functions. * lib.h (string_cmp, string_lt): Declarations renamed. (str_eq, str_gt, str_le, str_ge): New declarations. * txr.1: Document string-cmp to cmp-str rename, that string-lt is deprecated, and the new str<, str>, str>=, str<= and str= functions.
* Fixing issue with list-like iteration over generic sequences,Kaz Kylheku2014-06-061-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | namely that empty strings and vectors are not nil. The nullify function is introduced. It is also exposed to users, as is the existing make_like function. * eval.c (mapcarv, mappendv, lazy_mapcar, lazy_mapcarv): Use nullify to handle non-list inputs correctly. (eval_init): Registering make_like and nullify as intrinsics. * lib.c (copy_list, to_seq, list_collect_nconc, list_collect_append, reverse, lazy_appendv_func, lazy_appendv, ldiff, memq, memql, memqual, remq, remql, remqual, remove_if, keep_if, rem_lazy_rec, remq_lazy, remql_lazy, remqual_lazy, remove_if_lazy, keep_if_lazy, countqual, countql, countq, count_if, some_satisfy, all_satisfy, none_satisfy, do_chain, chainv, do_and, andv, do_or, orv, cat_vec, assoc, assql, mapcar, mapcon, mappend, sort, multi_sort, find, find_if, posqual, posql, posq, pos, pos_if, set_diff, search): Use nullify for correctness. Some functions fixed so return sequence matches type of input sequence. (nullify): New function. * lib.h (nullify): Declared. * txr.1: Documented nullify and ake-like.
* * eval.c (eval_init): Register new search function as intrinsic.Kaz Kylheku2014-06-061-0/+1
| | | | | | | | | | | * lib.c (search_list): New static function. (search): New function. * lib.h (search): New function declared. * txr.1: Documented. * txr.vim: Regenerated.
* * eval.c (eval_lisp1): Function removed.Kaz Kylheku2014-06-031-10/+5
| | | | | | (op_dwim, dwim_locs): Removing silly logic of separately calling eval_lisp1 on the functor, and eval_lisp1_args on its arguments, since lisp1 evaluation treats all position the same way.
* Documenting the return value of rplaca and rplacd, and changingKaz Kylheku2014-06-031-3/+4
| | | | | | | | | | | | it to be the cell, rather than the new value. * eval.c (transform_op): Fix use of rplacd that uses return value. (force): Likewise. * lib.c (rplaca, rplacd): Return cons. (rem_lazy_rec, obj_init): Fix use of rplacd that uses return value. * txr.1: Documented.
* The call operator should be a function!Kaz Kylheku2014-05-201-14/+6
| | | | | | | | * eval.c (call): New static function. (eval_args, op_call): Static functions removed. (eval_init): call_s registered as operator rather than function. * txr.1: Updated.
* * eval.c, gc.c, rand.c, regex.c, signal.c: Remove inclusion of unneededKaz Kylheku2014-04-131-1/+0
| | | | headers.
* * eval.c (make_var_shadowing_env): Remove unnecessary test forKaz Kylheku2014-04-111-8/+4
| | | | colon symbol.
* * eval.c (rangev_func, range_star_v_func): Use numericKaz Kylheku2014-04-081-3/+3
| | | | equivalence comparison for end test, rather than eql.
* Change to how locations are passed around, for the sake of generationalKaz Kylheku2014-03-291-44/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GC. The issue being solved here is the accuracy of the gc_set function. The existing impelmentation is too conservative. It has no generation information about the memory location being stored, and so it assumes the worst: that it is a location in the middle of a gen 1 object. This is sub-optimal, creating unacceptable pressure against the checkobj array and, worse, as a consequence causing unreachable gen 0 objects to be tenured into gen 1. To solve this problem, we replace "val *" pointers with a structure of type "loc" which keeps track of the object too, which lets us discover the generation. I tried another approach: using just a pointer with a bitfield indicating the generation. This turned out to have a serious issue: such a bitfield goes stale when the object is moved to a different generation. The object holding the memory location is in gen 1, but the annotated pointer still indicates gen 0. The gc_set function then makes the wrong decision, and premature reclamation takes place. * combi.c (perm_init_common, comb_gen_fun_common, rcomb_gen_fun_common, rcomb_list_gen_fun): Update to new interfaces for managing mutation. * debug.c (debug): Update to new interfaces for managing mutation. Avoid loc variable name. * eval.c (env_fbind, env_fbind): Update to new interfaces for managing mutation. (lookup_var_l, dwim_loc): Return loc type and update to new interfaces. (apply_frob_args, op_modplace, op_dohash, transform_op, mapcarv, mappendv, repeat_infinite_func, repeat_times_func): Update to new interfaces for managing mutation. * eval.h (lookup_var_l): Declaration updated. * filter.c (trie_add, trie_compress, trie_compress_intrinsic, * build_filter, built_filter_from_list, filter_init): Update to new * interfaces. * gc.c (gc_set): Rewritten to use loc type which provides the exact generation. We do not need the in_malloc_range hack any more, since we have the backpointer to the object. (gc_push): Take loc rather than raw pointer. * gc.h (gc_set, gc_push): Declarations updated. * hash.c (struct hash): The acons* functions use loc instead of val * now. (hash_equal_op, copy_hash, gethash_c, inhash, gethash_n, pushhash, Change to how locations are passed around, for the sake of generational GC. The issue being solved here is the accuracy of the gc_set function. The existing impelmentation is too conservative. It has no generation information about the memory location being stored, and so it assumes the worst: that it is a location in the middle of a gen 1 object. This is sub-optimal, creating unacceptable pressure against the checkobj array and, worse, as a consequence causing unreachable gen 0 objects to be tenured into gen 1. To solve this problem, we replace "val *" pointers with a structure of type "loc" which keeps track of the object too, which lets us discover the generation. I tried another approach: using just a pointer with a bitfield indicating the generation. This turned out to have a serious issue: such a bitfield goes stale when the object is moved to a different generation. The object holding the memory location is in gen 1, but the annotated pointer still indicates gen 0. The gc_set function then makes the wrong decision, and premature reclamation takes place. * combi.c (perm_init_common, comb_gen_fun_common, rcomb_gen_fun_common, rcomb_list_gen_fun): Update to new interfaces for managing mutation. * debug.c (debug): Update to new interfaces for managing mutation. Avoid loc variable name. * eval.c (env_fbind, env_fbind): Update to new interfaces for managing mutation. (lookup_var_l, dwim_loc): Return loc type and update to new interfaces. (apply_frob_args, op_modplace, op_dohash, transform_op, mapcarv, mappendv, repeat_infinite_func, repeat_times_func): Update to new interfaces for managing mutation. * eval.h (lookup_var_l): Declaration updated. * filter.c (trie_add, trie_compress, trie_compress_intrinsic, * build_filter, built_filter_from_list, filter_init): Update to new * interfaces. * gc.c (gc_set): Rewritten to use loc type which provides the exact generation. We do not need the in_malloc_range hack any more, since we have the backpointer to the object. (gc_push): Take loc rather than raw pointer. * gc.h (gc_set, gc_push): Declarations updated. * hash.c (struct hash): The acons* functions use loc instead of val * now. (hash_equal_op, copy_hash, gethash_c, inhash, gethash_n, pushhash,
* * eval.c (me_quasilist): New static function.Kaz Kylheku2014-03-251-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | (eval_init): Register me_quasilist as quasilist macro expander. * lib.c (quasilist_s): New global variable. (obj_init): quasilist_s initialized. * lib.h (quasilist_s): Declared. * match.c (do_txreval): Handle quasilist syntax. * parser.l (QWLIT): New exclusive state. Extend lexical grammar to transition to QWLIT state upon the #` or #*` sequence which kicks off a word literal, and in that state, piecewise lexically analyze the QLL, mostly by borrowing rules from quasiliterals. * parser.y (QWORDS, QWSPLICE): New tokens. (n_exprs): Integrate splicing form of QLL syntax. (n_expr): Integrate non-splicing form of QLL syntax. (litchars): Propagate line number info. (quasilit): Fix "string literal" wording in error message. * txr.1: Introduced WLL abbreviation for word list literals, cleaned up the text a little, and documented QLL's.
* * eval.c (expand_quasi): Bugfix: incorrect logic, failingKaz Kylheku2014-03-251-8/+11
| | | | | to macro-expand the embedded forms in a quasiliteral except when they are the very first item.
* * eval.c (eval_init): Register last function as intrinsic.Kaz Kylheku2014-03-231-0/+1
| | | | | | | | * lib.c (last): New function. * lib.h (last): Declared. * txr.1: Documented last.
* * eval.c (eval_init): Register empty as intrinsic.Kaz Kylheku2014-03-231-0/+1
| | | | | | | | | | | | * lib.c (copy): Bugfix: handle lazy strings. Also, handle hash tables via copy_hash. (length): Bugifx: handle lazy strings. Also, handle hash tables via hash_count. (empty): New function. * lib.h (empty): Declared. * txr.1: Documented.
* * eval.c (not_s): New symbol var.Kaz Kylheku2014-03-231-2/+27
| | | | | | | (me_unless, me_while, m_until): New static functions. (eval_init): Register macros unless, while and until. * txr.1: Document unless, while and until.
* * eval.c (me_when): New static function.Kaz Kylheku2014-03-221-0/+7
| | | | | | (eval_init): Register "when" macro. * txr.1: Documented when macro.
* * arith.c (tofloat, toint): New functions.Kaz Kylheku2014-03-191-0/+2
| | | | | | | | | * arith.h (tofloat, toint): Declared. * eval.c (eval_init): tofloat and toint registered as intrinsics. * txr.1: Documented.
* * eval.c (eval_init): Make seed argument optional in make-random-state.Kaz Kylheku2014-03-141-1/+1
| | | | | | | | | | | | | | | * rand.c (make_random_state): Do argument defaulting on seed. Also, mix getpid() into the seed. (random_fixnum): Bugfix: do proper defaulting on optional agument, rather than relying on nil. (random): Fix 2014-02-05 regression. This was totally broken, ignoring the random state passed in and using the global random state. This function must only use the state passed in; there is no defaulting to the global random state. * txr.1: Documenting that seed is optional in make-random-state. Describing what guarantees can be expected with regard to calls made close together temporally.