summaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
* * lib.c (copy): New function.Kaz Kylheku2014-02-271-1/+1
| | | | | | | | * lib.h (copy): Declared. * eval.c (eval_init): Registered copy function as intrinsic. * txr.1: Added missing documentation for length. Documented copy.
* * eval.c (maybe_progn): New function.Kaz Kylheku2014-02-271-2/+8
| | | | | (expand_macrolet, expand_symacrolet): Use maybe_progn to eliminate unnecessary progn wrapping.
* * eval.c (gun_s): New global variable.Kaz Kylheku2014-02-261-1/+12
| | | | | | | | (me_gun): New static function. (eval_init): New gun symbol interened, me_gun registered as intrinsic macro. * txr.1: Documented gun.
* Converting expander special case code transformations intoKaz Kylheku2014-02-261-50/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | formal macros that are in the top_mb table, make their symbols fboundp and can be expanded with macroexpand. * eval.c (mefun_t): New typedef name. (expand_macro): If the expander is a cobj, then pull out the C function and call it, otherwise realize the interpreted macro as before. (me_gen, me_delay): New static functions, replace expand_gen and expand_delay. (expand_qquote): Renamed to me_quote. (expand_gen, expand_delay): Renamed to me_gen and me_delay, with an interface adjustment and moved. (expand_op): Renamed to me_op. (expand): Removed qquote, gen, delay, op, and do handling, since these operators are now macros. Removed the unnecessary expansion of with-saved-vars. (reg_op, reg_fun): Assert that the symbol is not nil, to catch initialization order issues. One just showed up: op_do was interned in match.c, which is initialized later. (reg_mac): New static function (eval_init): Intern do_s, because match.c hasn't done it yet at this point. Register me_gen, me_delay, me_op (twice) and me_qquote as intrinsic macros. * txr.1: Documented those operators as macros.
* * eval.c (reg_op): New static function.Kaz Kylheku2014-02-261-45/+50
| | | | | (eval_init): Register operators with reg_op instead of direct sethash calls.
* * eval.c (do_eval): Set last_form_evaled just beforeKaz Kylheku2014-02-261-2/+3
| | | | dispatching function, so it is not clobbered by argument evaluations.
* * eval.c (expand_op): Use rlcp_tree when constructing theKaz Kylheku2014-02-261-6/+6
| | | | | | | | | | | | dwim_body, since the append2 copies list structure. * parser.y (n_exprs): propagate source loc info from both constituents, giving precedence to the left one, rather than just taking it from the left one and ignoring the second constituent. This fixes cases of missing location info. The left constituent n_expr is often a symbol, and those do not have location info. We want a case like like ((x) y) to take from (x), and (x (y)) to take it from (y), and so on.
* * eval.c (expand_place): Unnecessary, buggy function removed.Kaz Kylheku2014-02-261-78/+3
| | | | | | | | | | | | It was handling silly special cases with the net effect of being nearly equivalent to just expand, while failing to expand places which are compound macro calls. It did diagnose nonexistent place types at expansion time, which isn't worth much. (expand): All the expansions for the mutating operator sset, inc, dec, push, pop and flip were also pointless and have been removed. they did the precise equivalent of doing expand(rest(form)), and consing the symbol to the front, which is the fallback case for function call forms.
* * eval.c (eval_init): HAVE_MAKEDEV not HAVE_MKDEV.Kaz Kylheku2014-02-251-1/+1
|
* * configure: Added feature tests for makedev, link/symlink/readlink,Kaz Kylheku2014-02-251-2/+9
| | | | | | | | | | | | | | mkdir and mknod. * eval.c (eval_init): Wrap #ifdefs around the registrations of the wrappers for these functions. * stream.c (mkdir_wrap): Wrap in #ifdef HAVE_MKDIR, and provide a Windows version if HAVE_MKDIR is missing, but HAVE_WINDOWS_H is true. (makedev_wrap, major_wrap, minor_wrap): Wrap with #if HAVE_MAKEDEV. (mknod): Use #if HAVE_MKNOD. (symlink_wrap, link_wrap, readlink_wrap): Wrap with #if HAVE_SYMLINK.
* * eval.c (eval_init): Intern symlink_wrap, link_wrap, readlink_wrap.Kaz Kylheku2014-02-241-0/+3
| | | | | | | | * stream.c (symlink_wrap, link_wrap, readlink_wrap): New functions. * stream.h (symlink_wrap, link_wrap, readlink_wrap): Declared. * txr.1: Documented.
* * eval.c (eval_init): Register forgotten s_ifsock variable.Kaz Kylheku2014-02-241-0/+14
| | | | | | | | | | | | | | | | Register mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap and mknod_wrap. * stream.c (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): New functions. (stream_init): Initialize forgotten variable s-ifsock. * stream.h (s_ifsock): Declared. (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): Declared. * txr.1: Forgotten documentation for remove-path and rename-path added. Forgotten mention of s-ifsock. Documented new Unix functions.
* * eval.c (expand_qquote): Bugfix. Was not handling an unquoteKaz Kylheku2014-02-241-1/+3
| | | | | | | | | in the dotted position: (qquote x1 .. xn . (unquote form)), which looks like the structure (qquote x1 .. xn unquote form). Fixed by a hack: after recursively expanding the (unquote form) part (rest of the form), we check whether the unexpanded version has unquote at the front. If so, we know the expansion is just form, and use it to emit the suitable expansion.
* Symbol macros.Kaz Kylheku2014-02-241-31/+189
| | | | | | | | | | | | | | | | | | | | | | | | * eval.c (top_smb, defsymacro_s, symacrolet_s): New global variables. (lookup_symac, get_opt_param_syms, get_param_syms, op_defsymacro, expand_symacrolet, make_var_shadowing_env): New static functions. (expand_tree_cases, expand_catch_clause): Install shadowing environment so lexical bindings hide any symbol macrolets. (expand_place): Fix neglect to expand an atomic form, which breaks symbol macros used as places. (expand): Expand symbol macros, expand symacrolet binding forms. Make sure symbol macros are shadowed in the lexical binding constructs. Take advantage of return value of rlcp_tree in a few places. (macro_form_p): Support for symbol macros; bugfix: not handling default argument. (macroexpand_1): Streamlined, and support added for symbol macros. (eval_init): Protect top_smb from gc. Create new hash, stored in top_smb. Initialize defsymacro_s and symacrolet_s. Register op_defsymacro. * parser.y (rlcp_tree): Return the to form instead of useless t and nil. * txr.1: Documented.
* * eval.c (env_fbind, env_vbind): Use acons_new_c, and provideKaz Kylheku2014-02-231-45/+34
| | | | | | | | | | | | | | | | | | a much more useful return value: the binding cell itself, rather than the symbol. (bind_args): Bugfix: env_vbind was still being called in one case, leading to a neglect to bind a special variable properly. (bindings_helper): Changed interface. Bugfix: in sequential binding, actually bind the successive environments so closures will behave 100% correctly. Returns a list of the actual bindings, in which special variables are not distinguished in any way. (op_let, op_for): Conform to new bindings_helper interface. Use the lexical environment that it returns instead of making a new one. (op_each): Use the environment and list of bindings out of bindings_helper. The bindings are used for stepping the lists, and that includes stepping any special vars. The lexical environment is used for evaluating the body. Thus, we need no special processing for special vars here any more.
* * eval.c (bindings_helper): This must now bind dynamic valuesKaz Kylheku2014-02-231-74/+45
| | | | | | | | | | | | | | | rather than just assign to them. Got rid of the superfluous variable saving array. Fixed the problem in recognizing the special_s symbol (it is bindable). (op_with_saved_vars): This simplifies, since it no longer needs to save individual variables in an array, only to set up and tear down a new dynamic environment frame. (expand_vars): No longer returns two values with a cons. Takes a form argument for error reporting and a pointer to a boolean just to report whether there are special vars without listing them. (expand_save_specials): The with-saved-specials form doesn't need a var list any more, so the expander is updated not to stick them in. (expand): Update calls to expand_vars to new interface.
* Get special variable overriding working in function and macroKaz Kylheku2014-02-231-48/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parameter lists. There is a bugfix here too (see eval_init below). * eval.c (special_s): New global variable. This symbol is used as a marker in parameter lists denoting expander-generating syntax that gives information about specials. (lookup_var, looup_var_l): Bugfix: walk the dynamic chain properly. Fallback from the lexical chain to the dynamic. (env_vbind_special): New static function. (bind_args, bind_macro_params): Detect special list in params. Use env_vbind_special to bind variables either in the dynamic environment or the lexical one. (expand_opt_params, expand_params): Renamed to expand_opt_params_rec and expand_params_rec, respectively. Now take extra argument for accumulating list of special variables found in the param list. (expand_params): New static function. (set_dyn_env): New static function. (interp_fun, expand_macro): Set up and tear down new dynamic environment around parameter list evaluation and body evaluation. This will take any new dynamic bindings. (bindings_helper, op_each): The special_s symbol is now used instead of colon_k for marking specials. (op_defun): Recognize the specials added to the parameter list so as not to t report that as not a bindable symbol. (op_catch): Set up an tear down new dynamic environment around the evaluation of the catch clause param binding and body. (expand_vars): use colon_s symbol instead of colon_k for marking special var. (eval_init): Bugfix: gc-protect recently added dyn_env variable. Intern special symbol into special_s variable.
* Introducing some changes for improved handling of special variables.Kaz Kylheku2014-02-231-15/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Saving and restoring of individual variables is very silly and it's making it difficult to implement function parameters that are rebindings of special variables. Let's have a global pointer to a dynamic environment called dyn_env. Let's make it part of the extended_jmp_buf structure, so that it's implicitly saved and restored across exception handling. Special variable lookups go through the dyn_env chain, and fall back on the global bindings. To override some specials, we just push a new dynamic environment and stick them there. (As a bonus, the bindings can even be repeated in the lexical environment (i.e. the same objects), so they can be found faster. We have to make sure we remove that environment when we leave the scope in the normal way. If we unwind out, it is done automatically by extended_longjmp mechanism. * eval.c (dyn_env): New global variable. (lookup_var, lookup_var_l): If env is nil, look in the dyn_env first, and only if that fails, look in the global bindings top_vb. * signal.h (extended_jmp_buf): New member, de, for saving/restoring dyn_env. This structure is now used whether or not we have signals. (extended_setjmp, extended_longjmp): Updated to save and restore dyn_env, and to do it regardless of whether there is POSIX signal support. (dyn_env): Declared here.
* * eval.c (symbol_function): Retrieve the global macro binding if theKaz Kylheku2014-02-221-3/+6
| | | | | | | | | | | function lookup fails, and if that fails, retrieve the special operator binding. (fboundp): Report t if there is a global macro binding. * txr.1: Use "global" rather than "toplevel". Added note that the fun operator doesn't see macro bindings. Documented that symbol-function and fboundp see global macro bindings, and that symbol-function can retrieve a special operator binding.
* * eval.c (prinl, pprinl): New functions.Kaz Kylheku2014-02-221-0/+16
| | | | | | (eval_init): Registered as intrinsics. * txr.1: Documented.
* * eval.c (eval_intrinsic): We don't need to make an environmentKaz Kylheku2014-02-221-10/+7
| | | | | | | | | | | | | | | | | | here if the env parameter is nil. The low level environment lookup functions already handle nil. (do_eval): Do not type check the env argument for the ENV type. (expand_forms, expand): No need to default a missing menv to a blank environment; just use nil. (macro_form_p): Take menv parameter and switch to lookup_mac from gethash. (macroexpand_1, macroexpand): Use the environment parameter by using lookup_mac rather than gethash. (eval_init): Fix registration of macro_form_p to reflect new optional argument. * txr.1: Documented optional environment parameters in macro-form-p, macroexpand-1 and macroexpand. Documented macrolet.
* Implemented macrolet.Kaz Kylheku2014-02-221-3/+45
| | | | | | | | | * eval.c (macrolet_s): New variable. (lookup_mac, expand_macrolet): New static functions. (expand): Recognize and expand macrolet form. use lookup_mac to resolve macros rather than gethash, since we have lexical macros now. (eval_init): Intern macrolet symbol.
* * eval.c (bind_macro_params, expand_macro, macroexpand_1, macroexpand):Kaz Kylheku2014-02-221-13/+13
| | | | Rename mac_env variable to menv for consistency.
* Preparation for lexical macros: we need to pass a macroKaz Kylheku2014-02-221-95/+107
| | | | | | | | | | | | | | | | | environment down through the expander call hierarchy. * eval.c (expand_opt_params, expand_params, expand_tree_cases, expand_tree_case, expand_forms, val expand_cond_pairs, val expand_place, expand_qquote, expand_vars, expand_quasi, expand_op, expand_catch_clause, expand_catch, expand): All expanders get new parameter, menv. expand_forms and expand handle a nil value of menv. (eval_intrinsic): Pass nil macro environment to expand. (eval_init): Update intrinsic registration for expand. * eval.h (expand, expand_forms): Declarations updated. * parser.y (expand_meta): Gets macro env parameter. (elem, o_elem, exprs, expr): Pass nil to expand_forms and expand_meta.
* Replacing uses of the eq function which are used only as C booleans,Kaz Kylheku2014-02-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with just using the == operator. Removing cobj_equal_op since it's indistinguishable from eq. Streamlining missingp and null_or_missing_p. * eval.c (transform_op): eq to ==. (c_var_ops): cobj_equal_op to eq. * filter.c (trie_compress, trie_lookup_feed_char, filter_string_tree, html_hex_continue, html_dec_continue): eq to ==. * hash.c (hash_iter_ops): cobj_equal to eq. * lib.c (countq, getplist, getplist_f, search_str_tree, posq): eq to ==. (cobj_equal_op): Function removed. * lib.h (cobj_equal_op): Declaration removed. (missingp): Becomes a simple macro that yields a C boolean instead of t/nil val, because it's only used that way. (null_or_missing_p): Becomes inline function returning int. * match.c (v_output): eq to ==. * rand.c (random_state_ops): cobj_equal_op to eq. * regex.c (char_set_obj_ops, regex_obj_ops): cobj_equal_op to eq. (reg_derivative): Silly if3 expression replaced by null. (regexp): Redundant if2 expression wrapped around eq removed. * stream.c (null_ops, stdio_ops, tail_ops, pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops, cat_stream_ops): cobj_equal_op to eq. * syslog.c (syslog_strm_ops): cobj_equal_op to eq.
* The C function nullp is being renamed to null, and the rarelyKaz Kylheku2014-02-221-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | used global variable null which holds a symbol becomes null_s. A new macro called nilp is added that more efficiently checks whether an object is nil, producing a C boolean value rather than t or nil. Most of the uses of nullp in the codebase just become the more streamlined nilp. * debug.c (show_bindings): nullp to nilp * eval.c (lookup_var, lookup_var_l, lookup_fun, lookup_sym_lisp1, do_eval, expand_qquote, expand_quasi, expand_op): nullp to nilp. (op_modplace): nullp to null. (eval_init): Update registration of null and not from C function nullp to null. * filter.c (trie_compress, html_hex_continue): nullp to nil. (filter_string_tree): null to null_s. * hash.c (hash_next): nullp to nilp. * lib.c (null): Variable renamed to null_s. (code2type): null to null_s. (lazy_flatten_scan, chainv, lazy_str, lazy_str_force_upto, obj_print, obj_pprint): nullp to nilp. (obj_init): null to null_s; nullp to null. * lib.h (null): declaration changed to null_s. (nullp): Inline function renamed to null. (nilp): New macro. * match.c (do_match_line): nullp to nilp. * rand.c (make_random_state): Likewise. * regex.c (compile_regex): Likewise.
* Implementing special variables with local overriding.Kaz Kylheku2014-02-211-43/+162
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All predefined globals become special. * eval.c (special, with_saved_vars_s): New global variables. (mark_special, special_p): New functions. (bindings_helper): Takes new argument, include_specials. Now processes the special colon syntax for denoting special variables, setting up their values, taking care to observe whether the binding is parallel or sequential. (op_let, op_for): Pass new argument to bindings_helper. (op_each): Pass new argument to bindings_helper with a value of it, and deal with the colon annotations that emerge in the bindings. (op_defvar, regvar): Mark symbol as special. (op_with_saved_vars): New static function. (expand_vars): Takes new argument, returns a cons. Detects special variables among the vars and produces the colon syntax. (expand_catch_clause): Bugfix: this was using expand_vars on a parameter list. Now properly uses expand_params. (expand_save_specials): New static function. (expand): For the operators that are binding constructs, handle the new form of expand_vars which returns information about special variables. If specials occur, then generate the with-saved-vars form around the expansion which will save and restore their values. The expansion of vars done by expand_vars, together with the run-time actions of bindings_helper, do the rest. Speaking of which, the new with-saved-vars operator form is now expanded here too. (eval_init): Protect new variables special and with_saved_vars_s. Initialize special with new hash table. Store new interned symbol in with_saved_vars_s. Register op_with_save_vars in op_table. * txr.1: Documented specials.
* * eval.c (subst_vars): Change throwing of query_error_sKaz Kylheku2014-02-211-2/+1
| | | | | | to eval_error call. This is a leftover from when this was cloned from its counterpart in match.c. However, I can't think of a way this call can ever be reached.
* * eval.c (macro_form_p, macroexpand_1, macroexpand): New staticKaz Kylheku2014-02-201-0/+42
| | | | | | | functions. (eval_init): Registered new functions. * txr.1: Documented.
* * eval.c (env_hash): new function.Kaz Kylheku2014-02-181-0/+18
| | | | | | | | | | | | | | | | (eval_init): Register env and env_hash functions. Register prog_args and prog_args_full as *args* and *full-args*. * lib.c (timegm_hack): Invalidate env_list, after mucking with the environment via setenv and unsetenv. * txr.c (prog_args_full, prog_args): New global variables. (txr_main): Command-line processing converted to use TXR's library. Populates prog_args_full and prog_args. * txr.h (prog_args_full, prog_args): Declared. * txr.1: Documented *args*, *full-args*, env and env-hash.
* The mode argument in some stream-opening functions becomes optional.Kaz Kylheku2014-02-181-3/+3
| | | | | | | | | | * eval.c (eval_init): Change registration for open_file, open_tail and open_command. * stream.c (open_file, open_tail, open_command): mode_str argument defaulted. * txr.1: Updated.
* * eval.c (bind_args, op_defvar, op_defun, op_defmacro, op_modplace):Kaz Kylheku2014-02-171-5/+5
| | | | Fix sybol misspelling.
* * eval.c (eval_init): Register gensym function as the gensymKaz Kylheku2014-02-171-1/+2
| | | | | | | | | | | | | | intrinsic, rather than gensymv. Register gensym_counter as *gensym-counter*. * lib.c (gensym): Handle missing prefix argument by defaulting the prefix to "g". (gensymv): Function removed. * lib.h (gensymv): Declaration removed. * txr.1: Fixed omission: missing documentation for gensym. Documented *gensym-counter*.
* * eval.c (expand): Bugfix: do not expand any part of the macroKaz Kylheku2014-02-171-4/+1
| | | | | form via expand_forms. This is completely wrong since only the macro knows what material is evaluated and what isn't.
* * eval.c (op_tree_case): Removed superfluous handling ofKaz Kylheku2014-02-161-8/+5
| | | | | | | | nil parameter list; this is correctly handled by bind_macro_params. Added support for the colon symbol as an indication that the case is declined. * txr.1: Updated.
* New destructuring operators.Kaz Kylheku2014-02-161-11/+117
| | | | | | | | | | | | | | | | | * eval.c (tree_case_s, tree_bind_s): New symbol variables. (bind_macro_params): Bugfix: inappropriate exception thrown when atom matched against parameter list. Bugfix: nil being returned when atom matches empty parameter list. Added support for a new convention: if loose_p is the colon keyword, then exceptions are not thrown for destructuring mismatches; nil is returned instad. (op_tree_case, expand_tree_cases, expand_tree_case, op_tree_bind): New static functions. (expand): Handle tree_case_s and tree_bind_s. (eval_init): Intern tree-case and tree-bind symbols. Register the corresponding operator functions op_tree_case and op_tree_bind under these symbols in op_table. * txr.1: Documented tree-case and tree-bind operators.
* * eval.c (bind_macro_params): Bugfix: enforce mismatch onKaz Kylheku2014-02-161-0/+5
| | | | superfluous material.
* In the spirit of the previous hack, here is another hack toKaz Kylheku2014-02-161-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | alleviate a long-standing pain: when an exception happens in TXR's library somewhere, the program dies without leaving a clue about what code was being evaluated when that happened. What we can do is have the evaluator publish the most recent compound form it has processed by stashing it in a variable. Then when an unhandled exception occurs, we can peek at that and try to pull out source location info. * eval.c (last_form_evaled): New variable. (do_eval): When evaluating a compound form, stash it in last_form_evaled. (eval_init): Protect last_form_evaled from gc. * eval.h (last_form_evaled): Declared. (eval_error_s): Existing variable declared. * unwind.c: Has to include "eval.h" for the above variable and "parser.h" for the source_loc function. (uw_throw): When an exception is unhandled, if last_form_evaled has source info, add it to the diagnostic. But not if the exception is eval-error; because errors from the evaluators already have the info.
* Nice idea: how about a function which walks the tree structure andKaz Kylheku2014-02-161-2/+1
| | | | | | | | | | | | | | | | back-fills some missing source code location info. We apply this to macro expansions. If some error occurs in expanded code, this way it is referenced to the line where the macro *call* occurs. Not only is this better than nothing, it may be better than tracing it to the macro definition. Ideally, we would have both places: ("the error is in the code expanded from this macro, at this site"). * eval.c (expand): Use rlcp_tree to back-fill source info in macro expansion by taking it from the unexpanded form. * parser.h (rlcp_tree): Declared. * parser.y (rlcp_tree): New function.
* Bugfixes: not propagating source loc info in quasiliterals.Kaz Kylheku2014-02-161-3/+2
| | | | | | * eval.c (expand_quasi): Add some rlcp's here. * parser.y (o_var, quasi_items, o_elems_transform): Likewise.
* * eval.c (expand): Replace blatant tail calls withKaz Kylheku2014-02-161-3/+7
| | | | a backwards goto.
* * eval.c (bind_macro_params): Bugfix: the :whole parameter mustKaz Kylheku2014-02-151-1/+4
| | | | | | | | | capture the entire form, not just the arguments. (expand): Apply rlcp to the result of macro expansion, if it has not set up source code location. (eval_init): Register rlcp as intrinsic. * txr.1: Start of macro documentation. Documented rlcp.
* First cut at implementation of macros.Kaz Kylheku2014-02-151-7/+207
| | | | | | | | | | | | | | | * eval.c (top_mb, defmacro_s, macro_time_s, whole_k, env_k): New global variables. (expand_params): Recurse to handle macro parameter lists too. (bind_macro_params, op_defmacro, expand_macro): New static functions. (expand): Evaluate defmacro forms and macro-time forms at expansion time. Recognize and expand macros (albeit not yet with proper lexical scoping: local bindings are not able to shadow a macro). (eval_init): Protect top_mb from GC and initialize it. Intern new symbols defmacro, macro-time, and :whole. Register defmacro operator in op_table. * match.h (env_k): Added declaration for existing external variable.
* Bugfix: parameters of defun were not being treated by expander.Kaz Kylheku2014-02-151-8/+56
| | | | | | | | | | | They need to be since they can contain evaluable initforms for default arguments. Ditto with lambda; lambda parameters were being treated using expand_vars, which is not appropriate. * eval.c (expand_opt_params, expand_params): New static functions. (expand_vars): Bugfix: added some missing rlcp's to propagate line number info. (expand): Move lambda to separate case, and expand its params
* * eval.c (bind_args, op_modplace): Use ~s consistentlyKaz Kylheku2014-02-151-14/+14
| | | | in error messages.
* * eval.c (bindings_helper): Fixed misspelling of "symbol" in exceptionKaz Kylheku2014-02-151-1/+1
| | | | message.
* Replacing acons_new_l and aconsq_new_l interfaces with onesKaz Kylheku2014-02-141-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* * eval.c (eval_init): Registered hash_update_1 as intrinsic.Kaz Kylheku2014-02-141-0/+2
| | | | | | | | * hash.c (hash_update_1): New function. * hash.h (hash_update_1): Declared. * txr.1: Documented hash-update-1.
* Different approach: optional arguments on hash-isec and hash-uni allowKaz Kylheku2014-02-141-4/+2
| | | | | | | | | | | | | | | | | | | | | 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-141-0/+2
| | | | | | | | | | | * 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.