summaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
...
* * eval.c (expand_quasi): Regression: fix broken handlingKaz Kylheku2014-08-291-7/+1
| | | | | | of @{var mod} syntax triggering a bogus assertion. Mods are the third element in the abstract syntax now, not fourth. There is no next link. Removing bogus comment referring to a nonexistent function.
* Uprooting stupidities in handling of output variables.Kaz Kylheku2014-08-131-6/+3
| | | | | | | | | | | | | | | | | | | | * parser.y (o_elems_transform): Remove useless function which was only unwrapping the strange parse of output vars. (o_elems_opt, rep_elem, quasilit, wordsqlit): Eliminate o_elems_transform call. (o_var, q_var): Eliminate the phrase structure rules which match an extra o_elem or quasi_item, and which incorporate them into the var syntax tree element. Place the modifiers into the third position, not fourth. * eval.c (subst_vars): Eliminate handling of "pat" element. Actually that was not even there thanks to o_elems_transform being applied: dead code. Pull modifiers from the third element of the var form now, not fourth. * match.c (subst_vars): Similar changes as in the match.c subst_vars function. Here the pat variable is even more obviously useless; if it is not nil, it is just punted back to the spec.
* Bugfix: ret operator does not generate functionsKaz Kylheku2014-08-081-1/+3
| | | | | | | | | that take any number of arguments. * eval.c (me_ret): Generate (op identity (progn @rest <expr>)) rather than of (op identity <expr>). * txr.1: Update misleading equivalence.
* No getppid on MinGW.Kaz Kylheku2014-08-071-0/+6
| | | | | | * configure: Add test for getppid. * eval.c (getppid_wrap, eval_init): use HAVE_GETPPID
* * eval.c (eval_init): Fix incorrect registration ofKaz Kylheku2014-08-051-1/+1
| | | | | random-fixnum, which doesn't allow it to be called with no arguments.
* * eval.c (getpid_wrap, getppid_wrap): New static functions.Kaz Kylheku2014-07-301-0/+16
| | | | | | | | | (eval_init): Registered getpid and getppid intrinsics. * signal.c (kill_wrap): New static function. (sig-init): Registered kill intrinsic function. * txr.1: Documented getpid, gettpid and kill.
* * eval.c (eval_init): Register uniq function.Kaz Kylheku2014-07-291-0/+1
| | | | | | | | * lib.c (uniq): New function. * lib.h (uniq): Declared. * txr.1: Documented uniq.
* * eval.c (repeatv): Renamed to repeat. Turned into functionKaz Kylheku2014-07-291-6/+6
| | | | | | | | | with one optional argument, reflecting existing behavior. (eval_init): Registration of repeat updated. * txr.1: Fixed incorrect documentation which falsely suggests that repeat takes multiple lists, and doesn't mention the optional count.
* * eval.c (eval_init): Register nconc as intrinsic.Kaz Kylheku2014-07-291-0/+1
| | | | | | | | * lib.c (nconcv): New function. * lib.h (nconcv): Declared. * txr.1: Documented nconc.
* * eval.c (giterate_func, giterate): Adjusting semantics of giterate toKaz Kylheku2014-07-291-7/+3
| | | | | | | | include seed item in the sequence. The while test is applied to each item before it is passed through the function. Also, eliminated useless rplacd operation. * txr.1: Updated documentation of giterate.
* * eval.c (eval_init): Register partition-by intrinsic.Kaz Kylheku2014-07-281-0/+1
| | | | | | | | | * lib.c (partition_by_func): New static function. (partition_by): New function. * lib.h (partition_by): Declared. * txr.1: Documented partition-by.
* * eval.c (giterate_func, giterate): New static functions.Kaz Kylheku2014-07-271-0/+31
| | | | | | (eval_init): Registered giterate as intrinsic. * txr.1: Documented giterate.
* * 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.