summaryrefslogtreecommitdiffstats
path: root/eval.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce case{q,ql,qual}* macros which eval keys.Kaz Kylheku2016-11-121-3/+19
| | | | | | | | | | | | | | * eval.c (caseq_star_s, caseql_star_s, casequal_star_s): New symbol variables. (me_case): Implement new macro semantics. (eval_init): Initialize new symbol variables, and register the symbols to the me_case macro expander. * tests/sock-common.tl (local-addr): This function depends on the old broken caseql semantics which evaluate keys. Using caseql* makes it work again. * txr.1: Document case{q,ql,qual}* macros.
* Clause in case{q,ql,qual} with no forms yields nil.Kaz Kylheku2016-11-111-1/+3
| | | | | | | | * eval.c (me_case): If forms is nil, substitute the object (nil) for forms, to ensure a nil result through the expansion to a cond. * txr.1: Documented and added compat notes.
* Bugfix in case{q,ql,qual} macro expansion.Kaz Kylheku2016-11-111-6/+17
| | | | | | | | | * eval.c (me_case): The key must be quoted unconditionally whether it's an atom or list. Let's make this subject to the compatibility flag in case someone's code depends on it. * txr.1: Compat notes added.
* Streamline variable assignment operators slightly.Kaz Kylheku2016-11-111-15/+12
| | | | | | | | * eval.c (op_setq, op_lisp1_setq): Take the bindable(var) test out of the frequently executed path. We can safely do the variable lookup with any object. If the lookup fails, then we can complain that the object isn't a bindable symbol, if that is the case.
* Fix some gc-unsafe mutations found by inspection.Kaz Kylheku2016-11-101-1/+1
| | | | | | | | | | | | | | | | | | * eval.c (force): When replacing the promise by a forced value, we must use the set macro. Only the deref assignments which store symbols are safe, not the one storing ret. * lib.c (alist_nremove, alist_nremove1): We must use the set macro here instead of assigning through deref. Even though these assignments preserve the direction of the list (they just splice out nodes), it's possible that the list already contains a "wrong-way" reference (old generation to new) and that the node making this reference is appropriately marked to be processed properly in the next GC cycle. If we remove *that* node, we then cause its predecessor to point to the new generation node and that predecessor could be old generation.
* Implementing package foreign symbol concept.Kaz Kylheku2016-11-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register new intrinsics: package-local-symbols, package-foreign-symbols, use-sym, unuse-sym, use-package, unuse-package, unintern. * gc.c (mark_obj): Mark new hidhash member of struct package. * lib.c (make_package): Initialize new hidhash member of struct package. (lookup_package): New static function. (find_package): Allow string or symbol argument. (get_package): New static function. (delete_package, package_symbols): Use get_package for flexible package argument; delete_package removes symbols from other packages via unuse_package. (package_local_symbols, package_foreign_symbols): New functions. (use_sym, unuse_sym): New functions. (resolve_package_designators): New static function. (use_package, unuse_package): New functions. (symbol_present): New static function. (intern): Revised with get_package for flexible package argument. (unintern): New function. (rehome_sym): Use get_package. Semantics revised. (obj_print_impl): Use symbol_present function to determine whether object is visible in *package* and can be printed without a prefix, rather than naive home package test. * lib.h (struct package): New member, hidhash. (package_local_symbols, package_foreign_symbols, use_sym, unuse_sym, use_package, unuse_package, unintern): Declared. * txr.1: Documentation updated. Extended section introducing the design of packages, and argument conventions. New functions described. Existing function descriptions revised, particularly rehome-sym. Missing description of delete-package added.
* Implement *package* special var; package overhaul.Kaz Kylheku2016-11-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (load): Rebind *package* in the local dynamic environment already established for the sake of *load-path*. By doing this we cause *package* to be restored to its prior value, which allows the loaded file to alter it. Common Lisp works this way. (eval_init): Register *package* variable, with the user package as its default value. * lib.c (package_s): New symbol variable. (intern, rehome_sym): Default the package argument to the current package, not to user_package. (get_user_package, get_system_package, get_keyword_package): Functions removed. (get_current_package): New function. (obj_print_impl): Revise symbol printing. Keyword and uninterned symbols are printed with : and #: prefixes. The remainder are printed with a package prefix if their home package isn't the current package. * lib.h (keyword_package, user_package, system_package): These macros are just straight aliases for the global variables, not going through the lookup mechanism, which was pointless. (cur_package): New macro. (package_s): Declared. (get_current_package): Declared. * lisplib.c (lisplib_try_load): Establish a local dynamic environment, and bind the *package* variable to the user package which the library modules expect. * parser.c (find_matching_syms, provide_completions): Treat unqualified symbols in the current package rather than user package. * parser.y (sym_helper): Intern unqualified symbols in the current package, not user package. * txr.1: Document that the variables user-package, system-package and keyword-package should not be modified. Document the *package* special variable, and that intern and rehome-sym default their package argument to its value. (Here we get rid of wrong references to the undocumented variable *user-package*).
* Deprecated undocumented *user-package* etc.Kaz Kylheku2016-11-081-3/+5
| | | | | | | | | | | * eval.c (eval_init): Do not register *user-package*, or *system-package* or *keyword-package* variables unless in compatibility mode. We don't document this in the compatibility notes since the variables are not documented. * tests/009/json.txr: Change use of *keyword-package* to keyword-package.
* Don't track macro origin of interned objects.Kaz Kylheku2016-11-041-1/+3
| | | | | | * eval.c (set_origin): If either form or origin isn't a heap object, or is an interned symbol, then don't record the relationship.
* Don't print distracting path in error trace.Kaz Kylheku2016-11-041-2/+2
| | | | | | * eval.c (error_trace): No need to indicate where an expansion was calculated; it is distracting information when the exception isn't happening at expansion time.
* No need to track origin of entire macrolet.Kaz Kylheku2016-11-041-4/+1
| | | | | | | | | | * eval.c (expand_macrolet): Do not call set_origin to establish a macro ancestry link between the output of the expansion and the original macrolet block. This is not necessary. What is useful and important that the individual expansions of the actual macrolets have their origins tracked to the respective subforms of the original macrolet form. That's already taken care of by expand_macro.
* Show location of expanded form in exp-time errors.Kaz Kylheku2016-11-041-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Old behavior: | 1> (sys:expand '(defstruct foo bar)) | ** defstruct: inheritance base bar does | not name a struct type | ** during expansion at | /usr/local/share/txr/stdlib/struct.tl:120 | of form (defstruct foo bar) New behavior: | 1> (sys:expand '(defstruct foo bar)) | ** defstruct: inheritance base bar does | not name a struct type | ** during expansion at expr-1:1 of form (defstruct foo | bar) | ** by macro code located at | /home/kaz/txr/share/txr/stdlib/struct.tl:120 * eval.c (error_trace): Show location of the form being expanded in the "during expansion" message, rather than, confusingly, the locaton of the code of its macro. Then, if the location of the macro is available, show that in a separate message whose wording makes it clear that the location of the expanding macro is being given.
* New negated equality test functions.Kaz Kylheku2016-11-011-0/+3
| | | | | | | | | * eval.c (eval_init): Register neq, neql and nequal intrinsics. * lib.h (neq, neql, nequal): New inline functions. * txr.1: Documented neq, neql and nequal
* Relax restrictions on dwim places.Kaz Kylheku2016-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No longer require the leftmost expression in a dwim place to itself be a place, except when the expression evaluates to a list, and the list is subject to an element deletion or a range operation. * eval.c (eval_init): Register dwim-set and dwim-del with one additional argument that the C functions now take. * lib.c (dwim_set, dwim_del): Take a new place_p argument which informs these functions whether the object they are operating on came from a syntactic place. The forbidden situations are diagnosed based on this flag: modification of the subrange of a list, or deletion of a list ref. Some error messages reworded. * lib.h (dwim_set, dwim_del): Declarations updated. * share/txr/stdlib/place.tl (defplace dwim): Produce a different update, clobber and delete expansion when the obj-place form isn't a place. In the non-place case, do not assign the result of the sys:dwim-set or sys:dwim-del operation back obj-place. Furthermore, pass a Boolean flag to sys:dwim-set and sys:dwim-del indicating which situation is the case: did the object argument come from a place or non-place. * txr.1: Documentation updated.
* lambda-set method: treat [struct ...] as place.Kaz Kylheku2016-10-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Extend symbol-function accessor to methods.Kaz Kylheku2016-10-291-0/+8
| | | | | | | | | | | | | | | | | | * eval.c (looup_fun): Handle (meth ...) syntax. * share/txr/stdlib/place.tl (sys:get-fb): Function removed. (sys:get-fun-getter-setter): New function. (defplace symbol-function): Rework getter and setter using new function which works for method as well as regular function bindings. * txr.1: Documentation updated in several places. The mention of symbol-function in the list of place forms altered so it doesn't insinuate that the argument must be a symbol. Description of symbol-function updated. Also under the trace and untrace macros, a note added that tracing methods is possible.
* last, butlast: become accessors, get optional arg.Kaz Kylheku2016-10-261-6/+6
| | | | | | | | | | | | | | | | | | | | * eval.c (optimize_qquote_form): Pass nil to default new argument of butlast. (me_whilet, me_iflet_whenlet): Likewise for last. (eval_init): Add optional argument to registration of last and butlast intrinsics. * lib.c (last, butlast): Support optional numeric argument, like in Common Lisp. * lib.h (last, butlast): Declarations updated. * share/txr/stdlib/place.tl (last, butlast): New place macros. * txr.1: Updated documentation. The description of last is now moved into the sequence functions section.
* New accessors nthlast and butlastn.Kaz Kylheku2016-10-251-0/+2
| | | | | | | | | | | | | | * eval.c (eval_init): register nthlast and butlastn intrinsicis. * lib.c (nthlast, butlastn): New function. * lib.h (nthlast, butlastn): Declared. * share/txr/stdlib/place.tl (defplace nthlast, defplace butlastn): New places. * txr.1: Documented nthlast and butlastn.
* Don't expand macros in quasiquote expander.Kaz Kylheku2016-10-241-27/+24
| | | | | | | | | | | | | | | The quasiquote expander does something very odd: it passes the macro-time environment through its recursion and calls expand on some forms. Why was this done? Perhaps it helps promote certain optimizations. In any case, it gets in the way of being able to expand quasiquotes in a non-macro context. * eval.c (expand_qquote_rec): Lose menv argument, and eliminate all expand calls. (expand_qquote): Lose menv argument, and don't pass it down to expand_qquote_rec. (me_qquote): Ignore menv argument; don't pass it down to expand_qquote.
* Fix non-working quasiquote over struct literals.Kaz Kylheku2016-10-241-0/+4
| | | | | | | | | | | | | | | | | | | | Turns out that there is missing support for quasiquoting over structs. Code analogous to the way vector and hash literals are handled is missing for structs. * eval.c (expand_qquote_rec): Handle struct_lit_s forms specially, like hash_lit_s and vector_lit_s. commit 1e5bc5708d5763f20a7774f9348e825304a51adc * struct.c (make_struct_lit_s): New symbol variable. (struct_init): Store interned sys:make-struct-lit symbol into make_struct_lit_s, and use that to register the function. * struct.h (make_struct_lit_s): Declared. * tests/012/struct.tl: Update struct literal quasiquote test cases to reflect fixed behavior.
* Changes to the printing framework.Kaz Kylheku2016-10-201-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The print function now takes an optional boolean for pretty printing. The print method is also called with a third argument; hence structures can customize both standard printing and pretty printing. * lib.c (obj_print): Take pretty argument, and pass it down to obj_print_impl. This makes obj_pprint redundant. (obj_pprint): Function removed: it was identical to obj_print except for passing t down to obj_print_impl for the pretty argument. These two wrappers had started small and got bigger with identical changes done in parallel. (pprint): New function. (tostring, dump): Pass nil for pretty argument of obj_print. (tostringp): Use pprint instead of obj_pprint. * lib.h (obj_print): Declaration updated. (obj_pprint): Declaration removed. (print, pprint): Declared. * eval.c (prinl): Pass nil for pretty_p argument of obj_print. Do the stream defaulting here; obj_print doesn't do it. (pprinl): Pass t for pretty_p argument of obj_print, and do stream argument defaulting. (eval_init): Register print to new print function rather than directly to obj_print. Register pprint to new pprint function rather than obj_pprint. * hash.c (hash_print_op): Call obj_print_impl to print the :equal-based keyword, rather than obj_print. Pass down the pretty flag. All the other keywords are treated this way; this fixes an inconsistency. * match.c (dump_var): Call pprint instead of obj_pprint. * stream.c (formatv): Call obj_print, with a calculated pretty argument instead of switching between obj_pprint and obj_print. * struct.c (struct_inst_print): Except when in backward compatibility mode, call the object's print method in both pretty and regular printing mode, passing the mode as a third argument. * tests/012/oop.tl (defstruct animal): Support third argument in print method. Make it optional because there are some explicit calls which don't pass the argument. * txr.1: Documentation updated for print method and the print function. Revised text for some of the related functions. Added compat notes.
* Support nil env in env-fbind and env-vbind.Kaz Kylheku2016-10-151-10/+24
| | | | | | | | * eval.c (env_fbind, env_vbind): Allow env to be nil, indicating that the binding is to take place in the global environment. * txr.1: Documented.
* Synchronize license comments with LICENSE.Kaz Kylheku2016-10-011-16/+17
| | | | | | | | | | | | | | | | | | | | * Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
* Change criterion for *load-path*-relative loading.Kaz Kylheku2016-09-271-1/+1
| | | | | | | | | | * eval.c (load): Do not resolve all relative paths relative to the current *load-path*, only pure relative ones. * match.c (v_load): Likewise. * txr.1: Update doc for @(load)/@(include) and load function.
* Get rid of sys:load; load becomes function.Kaz Kylheku2016-09-261-28/+7
| | | | | | | | | | | | | | | | | * eval.c (sys_load_s): Variable removed. (sys_load): Function removed. (load): Body of function taken from sys_load. There is no sloc argument; the *load-path* variable is sampled via new load_path macro. (me_load): Static function removed. (eval_init): Remove initialization of sys_load_s Remove registration of load macro and sys:load function. Register load function. * eval.h (load_path): New macro. * txr.1: Change documentation of load from macro to function.
* Overhaul of self-load-path mechanism.Kaz Kylheku2016-09-261-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The self-load-path symbol macro is as of now deprecated. It simply expands to *load-path*. *load-path* is a new special variable which is dynamically bound to the path of a file being loaded. * eval.c (self_load_path_s): Global variable renamed to load_path_s. (sys_load): Bind *load-path* around processing of loaded file. (me_load): Expand (load x) simply to (sys:load x *load-path*). (set_get_symacro): Function removed. (reg_symacro): New static function. (eval_init): Initialize renamed load_path_s with interned symbol having the name *load-path*. Register the *load-path* special variable. Set up the sel-load-path symbol macro aliasing for *load-path*. * eval.h (self_load_path_s): Declaration renamed. * match.c (v_load): Bind *load-path* around loading or inclusion. * parser.c (load_rcfile): Bind *load-path* around loading of .txr_profile file. * txr.c (txr_main): Bind *load-path* instead of self-load-path symbol macro. * txr.1: Updated documentation for @(load) directive and load macro. Replaced documentation of self-load-path with *load-path*.
* New functions: tofloatz and tointz.Kaz Kylheku2016-09-241-0/+2
| | | | | | | | | | * arith.c (tofloatz, tointz): New functions. * arith.h (tofloatz, tointz): Declared. * eval.c (eval_init): Register tofloatz and tointz intrinsics. * txr.1: Documented new functions.
* eval: error message change.Kaz Kylheku2016-09-231-1/+1
| | | | | | | * eval.c (do_eval): The no such function or operator message is replaced with one which makes it clear that this means that the first element of the form doesn't name an operator or function.
* Move regex intrinsic registrations to regex.c.Kaz Kylheku2016-09-211-14/+0
| | | | | | | | * eval.c (eval_init): Remove all regex-related function registrations from here. * regex.c (regex_init): Move regex-related function registrations here.
* split-str gains ability to keep separating pieces.Kaz Kylheku2016-09-161-1/+1
| | | | | | | | | | | | | | | * eval.c (eval_init): Register split-str to split_str_keep, with optional argument. * lib.c (split_str_keep): New function, formed from split_str, with third argument. (split_str): Reduced to wrapper around split_str_keep. Thus we don't have to update umpteen existing calls with an extra nil parameter. * lib.h (split_str_keep): Declared. * txr.1: Documented new optional argument of split-str.
* Merge macro expanders for while and until.Kaz Kylheku2016-09-161-27/+14
| | | | | | | | | | | * eval.c (me_while, me_until, me_while_star, me_until_star): Functions removed. (me_while_until, me_while_until_star): New functions. Here we just check the form symbol and add the negation to the test. Also: use of (zap flag) in the while* and until* expansion has been replaced with (set flag nil), because zap wastefully arranges to yield the prior value, which is not used at all.
* fix broken while* and until*.Kaz Kylheku2016-09-161-2/+2
| | | | | eval.c (me_while_star, me_until_star): for loop test must be a sequence of forms, not a single form.
* key function argument on remq, remql and remqual.Kaz Kylheku2016-09-151-4/+4
| | | | | | | | | | | | | | | | | * eval.c (weave_while): Pass third arg to remq as nil. (eval_init): Update registrations of remq, remql and remqual. * lib.c (remq, remql, remqual): Implement key function argument. * lib.h (remq, remql, remqual): Declarations updated. * sysif.c (at_exit_call): Pass third arg to remq as nil. * debug.c (debug): Pass third argument to remqual as nil. * txr.1: Documentation updated.
* New keepq, keepql and keepqual functions.Kaz Kylheku2016-09-151-0/+3
| | | | | | | | | * eval.c (eval_init): Register keepq, keepql and keepqual intrinsic functions. * lib.c (keepq, keepql, keepqual): New functions. * lib.h (keepq, keepql, keepqual): Declared.
* Fix bugs in new quasiquote optimization.Kaz Kylheku2016-08-281-2/+4
| | | | | | | | | | | * eval.c (qquote_init): Stricter quote_form_p_f test function: reject the quote form if it isn't a proper list of two elements. (optimize_qquote_form): Extract all arguments of list forms and catenate them with mapcan, rather than assuming that they have one argument. This wrong assumption breaks ,,*(list ...) interpolation, for instance.
* Precompute functions used by quasiquote optimizer.Kaz Kylheku2016-08-281-35/+46
| | | | | | | | | | | | * eval.c (consp_f, second_f, list_form_p_f, quote_form_p_f, xform_listed_quote_f): New static variables. (qquote_init): New function. (optimize_qquote_form): Use list_form_p_f, quote_form_p_f, and second_f instead of constructing functions locally. (optimize_qquote_args): Use xform_listed_quote_f instead of locally constructed function. (eval_init): Call qquote_init. Register second function to second_f.
* Optimize quasiquote code generation.Kaz Kylheku2016-08-271-9/+98
| | | | | | | | | | | | | | | | | The surface motive here is to get better code than forms like (append (list 'a) (list 'b) ...). The ulterior motive is to suppress the memory explosion when heavily nested forms like ^^^^^^^^^^^x are expanded. This problem was uncovered by AFL (fast). * eval.c (optimize_qquote_form, optimize_qquote_args, optimize_qquote): New static functions. (expand_qquote_rec): New function. (expand_qquote): Contents moved into expand_qquote_rec. This function now optimizes the results of calling expand_qquote_rec.
* Introduce symbol variable for list*.Kaz Kylheku2016-08-271-2/+3
| | | | | | * eval.c (list_star_s): New symbol variable. (eval_init): Initialize list_star_s and use it for the list* function registration.
* Put cap on @<digits> value in op/do syntax.Kaz Kylheku2016-08-241-0/+4
| | | | | | | | | | | | | | | | The op transformer generates a lambda which has as many arguments as the highest-valued metanumber (@<digits> syntax) occurring in the form. If this is a huge integer, it obligingly tries to construct the argument list, running out of memory. In this commit, we cap the value to 1024. This issue was uncovered by the fuzzing utility AFL (fast) 2.30b. * eval.c (me_op): Throw error if max exceeds 1024, preventing the call to supplement_op_syms to actually generate an a formal parameter list of max symbols.
* Error on non-bindable sym in defvar and defparm.Kaz Kylheku2016-08-241-0/+3
| | | | | | * eval.c (me_def_variable): Check for sym not being a bindable symbol. Otherwise we might call mark_special on nil, which triggers an assertion.
* Fix bug: global lexicals marked special anyway.Kaz Kylheku2016-08-241-9/+4
| | | | | | | | | | | | | | Variables defined with defvarl or defparml are being marked special, due to a mark_special call in the macro expander which existed before they were introduced. * eval.c (me_def_variable): We have to call mark_special at macro-expansion-time for defparm and defvar, rather than arrange for it to be called later, for the same reasons that the (now incorrect) mark_special call had been introduced in do_expand function for handling defvar. (do_expand): Do not call mark_special, because the symbol being handled here is defvarl: define lexical variable.
* Check arg count when expanding defsymacro.Kaz Kylheku2016-08-241-0/+3
| | | | | | * eval.c (do_expand): Throw error if defsymacro form isn't a list of three elements, just like defparm and defparml do.
* Misleading error message in defvarl and defsymacro.Kaz Kylheku2016-08-241-2/+2
| | | | | | * eval.c (op_defvarl, op_defsymacro): Report correct symbol in not-bindable-symbol error message rather than reporting as let.
* Adding time-parse function: wrapper for strptime.Kaz Kylheku2016-08-221-0/+1
| | | | | | | | | | | | * configure: Test for strptime. * eval.c (eval_init): register time-parse intrinsic. * lib.c (time_parse): New function. * lib.h (time_parse): Declared. * txr.1: Documented.
* defsymacro must remove special marking.Kaz Kylheku2016-06-111-0/+2
| | | | | | | | | | * eval.c (op_defsymacro): Remove sym from the special hash, unless compatibility 143 or lower is requested. * txr.1: Document effects of evaluating defsymacro if a global variable of the same name exists, and the behavior in lexical scopes where sym is bound. Added compatibility notes covering the code change.
* Fixing semantics of makunbound.Kaz Kylheku2016-06-081-3/+19
| | | | | | | | | | | | | | | | | | * eval.c (unbound_s): New symbol variable. (lookup_var): If a dynamic binding has the special sys:unbound symbol as its value, then return nil, so the behavior is as if there is no binding. (makunbound): If the symbol exists in a dynamic environment, then replace its value with sys:unbound, making it look unbound. (eval_init): Initialize unbound_s. * lib.h (us_car, us_cdr): New inline functions. * txr.1: New dialect notes under boundp. Updated the makunbound documentation. Separated makunbound documentation from fmakunbound and mmakunbound. Added compatibility notes.
* Fixes in field formatting diagnostics.Kaz Kylheku2016-06-041-5/+6
| | | | | | * eval.c (format_field): Improve error messages; streamline some code, report expression value rather than expression itself for bad modifier.
* Move registration of hash module functions to hash.cKaz Kylheku2016-05-281-41/+1
| | | | | | | | | | | | | | | * eval.c (gethash_s): Global symbol variable removed, due to being used only in one place. (eval_init): Remove registration of make-hash, make-similar-hash, copy-hash, hash, hash-construct, hash-from-pairs, hash-list, inhash, sethash, pushhash, remhash, hash-count, get-hash-userdata, set-hash-userdata, hashp, maphash, hash-eql, hash-equal, hash-keys, hash-values, hash-pairs, hash-alist, hash-uni, hash-diff, hash-isec, hash-subset, hash-proper-subset, group-by, group-reduce, hash-update, hash-update-1, hash-revget, hash-begin, hash-next. * hash.c (hash_init): Registrations removed from eval_init moved here.
* Track origin across op/do expansion.Kaz Kylheku2016-05-231-0/+2
| | | | | | | | * eval.c (me_op): We tell a little lie here, by indicating that the "dwim body" is an expansion of the op operator. Of course, the entire lambda containing that body is that expansion. But in error messages, we need something useful for the user.
* Use sys_load_s symbol variable.Kaz Kylheku2016-05-181-1/+1
| | | | | | * eval.c (eval_init): Use sys_load_s variable set up earlier in the function instead of redundant call to intern.