summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Resolve method name to supertype.Kaz Kylheku2015-12-011-1/+17
| | | | | | * struct.c (method_name): Don't return first match. Resolve to most ancestral superclass which has that function in the same slot.
* Suppress superfluous "located at" message.Kaz Kylheku2015-11-301-9/+5
| | | | | * eval.c (error_trace): Restructure loop. Suppress "which is located at" message in first iteration.
* Some missing exceptions to indentation rule.Kaz Kylheku2015-11-301-1/+2
| | | | | * genvim.txr: Indent new, lnew, meth, umeth and usel forms like function calls.
* defun can define methods.Kaz Kylheku2015-11-303-10/+49
| | | | | | | | | | | | * eval.c (op_defun): Handle (meth type name) syntax in place of name via sys:defmeth function, which is dynamically resolved and autoloaded as necessary. (builtin_reject_test): When defun is being checked, recognize a (method ...) form and allow it. * struct.h (meth_s): Declaration added. * txr.1: Documented new defun capability.
* Correct return value of defmeth.Kaz Kylheku2015-11-301-3/+4
| | | | | * share/txr/stdlib/struct.tl (defmeth): Return the symbol being defined.
* Refactor propagation of contexts in evaluator.Kaz Kylheku2015-11-304-63/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The context form arguments become just context objects in various places. When a context form is actually needed, or the context's symbolic name, they must be retrieved via functions applied to a context. * debug.c (debug): form argument is now a context. Use the ctx_form function to retrieve the form. * debug.h (debug_check): Rename form parameter to ctx. * eval.c (ctx_form, ctx_name): New functions. (eval_error): Leftmost parameter is a context now. Use ctx_form API to obtain the context form from this object, from which the source location info can then be retrieved as before. (abbrev_ctx): Function removed. (bind_args, bindings_helper, fbindings_helper): Convert ctx_form argument to ctx, and use the API to access name or form. (do_eval, do_eval_args, eval, eval_args_lisp1, eval_lisp1, eval_progn, eval_prog1): ctx_form param renamed to ctx. (funcall_interp): Pass the original interpreted function as the context to bind_args, not the extracted code. When ctx_name sees this object, it will compute the function name, which was not possible from the code being used as the context. This is the big reason for all these changes. * eval.h (eval_error): Declaration updated. (ctx_form, ctx_name): Declared.
* Drop ctx_form param on env_vbind_special and apply.Kaz Kylheku2015-11-303-26/+26
| | | | | | | | | | | | | | | | | * eval.c (env_vbind_special): Remove unused ctx_form parameter. (bind_args, bind_macro_params): Don't pass ctx_form to env_vbind_special. (apply): Remove unused ctx_form parameter. (apply_intrinsic, applyv, mapcarv, mappendv, lazy_mapcarv_func, mapdov, do_mapf): Don't pass nil third argument to apply. * eval.h (apply): Declaration updated. * lib.c (do_juxt): Do not bind third argument of apply to lin when currying; curry as two argument function. (do_not): Do not pass third nil argument to apply.
* Change funcall_interp API.Kaz Kylheku2015-11-303-9/+10
| | | | | | | | | | | | | | * eval.c (funcall_interp): Drop the env argument. The fun argument is now the whole function object, not the encapsulated code to be interpreted. We pull the environment and code out of the object locally and interpret as before. * eval.h (funcall_interp): Declaration updated. * lib.c (generic_funcall, funcall, funcall1, funcall2, * funcall3, funcall4): Calls to funcall_interp simplified, just passing fun.
* Rename interp_fun function.Kaz Kylheku2015-11-303-9/+9
| | | | | | | | | * eval.c (interp_fun): Function renamed to funcall_interp. * eval.h (interp_fun): Declaration updated. * lib.c (generic_funcall, funcall, funcall1, funcall2, funcall3, funcall4): Calls to interp_fun updated.
* func-get-name calculates a name for methods.Kaz Kylheku2015-11-304-19/+72
| | | | | | | | | | | | | | * eval.c (func_get_name): Use try to use new method_name function, if unable to get name from the lexical or global environment for functions. * struct.c (meth_s): New symbol variable. (struct_init): Initialize meth_s variable. (method_name): New function. * struct.h (method_name): Declared. * txr.1: Re-documented func-get-name.
* Version 126.txr-126Kaz Kylheku2015-11-296-516/+549
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Increase stack size on Windows.Kaz Kylheku2015-11-292-1/+17
| | | | | | | | | * Makefile: include CONF_LDFLAGS in LDFLAGS. * configure (conf_ldflags): New variable. (gen_config_make): Generate CONF_LDFLAGS make variable. New test which sets up conf_ldflags for a 16Mb stack size if we are on Cygwin or MinGW.
* Bugfix: split and partition again.Kaz Kylheku2015-11-291-2/+3
| | | | | | | | * lib.c (partition_split_common): nullify indices after calling function, because function can put out an empty sequence of non-list type. Use "not sequence" test rather than "atom" on final index list, so that vectors and strings can specify indices, as documented.
* Improve destructuring error messages.Kaz Kylheku2015-11-291-4/+4
| | | | | | | * eval.c (bind_macro_params): On mismatch between atom and param list, or insufficient parameters for list, report which params are mismatched. In a nested destructuring syntax, it is difficult to know.
* Bugfix: destructive behavior in transpose.Kaz Kylheku2015-11-281-1/+1
| | | | | | | | * lib.c (transpose): This function turns an input list into an argument list which ends up in an args structure, which potentially destroys it to prevent spurious retention. The list must be copied. We don't use copy-list because the function supports vectors.
* Error reports trace through layers of macroexpansion.Kaz Kylheku2015-11-284-60/+63
| | | | | | | | | | | | | | | | | | | | * eval.c (error_trace): New function. Consolidates error reporting between unhandled exception handling in uw_throw, and the catcher in the repl. (op_defmacro, expand_macrolet): Propagate location info from body to wrapping block, and to the macro binding. In the latter function, also to the body that is wrapped by local macros. (do_expand, macroexpand_1): Propagate location info from macro expander to expansion, only taking it from the form if the macro doesn't supply it. * eval.h (error_trace): Declared. * parser.c (repl): Replace error reporting code with call to error_trace. * unwind.c (uw_throw): uw_throw: likewise.
* Propagate location info in progn optimization.Kaz Kylheku2015-11-281-1/+1
| | | | * eval.c (maybe_progn): rlcp info to generated progn cons.
* Improve source loc copying in expand_qquote.Kaz Kylheku2015-11-281-5/+5
| | | | | | * eval.c (expand_qquote): Use rlcp_tree to propagate source location more completely. Also, it was missing in the quote case.
* Remove useless test from rlcp_tree.Kaz Kylheku2015-11-281-5/+4
| | | | | * parser.y (rlcp_tree): Remove redunant test, around the for loop, of a condition which is the same as its guard condition.
* WIP: fix erroneous use of rlcp that should be rl.Kaz Kylheku2015-11-261-8/+7
| | | | | * parser.y (hash, struct, range): Fix rlcp being wrongly used to copy nonexistent line number info from an integer.
* Report chain of macro-expansions in errors.Kaz Kylheku2015-11-254-6/+36
| | | | | | | | | | | | | | | * eval.c (origin_hash): New global variable. (lookup_origin): New function. (expand_macro): Enter original form into origin hash, keyed by new form. (eval_init): gc-protect and initialize origin_hash. * eval.h (lookup_origin): Declared. * parser.c (repl): Report chain of expansions from last_form_evaled. * unwind.c (uw_throw): Likewise.
* Bugfix: sethash doesn't return stored value.Kaz Kylheku2015-11-252-8/+12
| | | | | | | | | | | | | | | | sethash mistakenly returns a boolean which indicates that the value was newly added, rather than the documented behavior of returning the new value. * hash.c (sethash): return value rather than new_p. * share/txr/stdlib/place.tl (defplace): The defplace form now seturn the main symbol of the place being defined, rather than returning whatever the last sethash call returns. (define-place-macro): Likewise. (sys:register-simple-accessor): Likewise, so that defaccessor returns the getter function's name.
* Better no such type diagnostic in defmeth.Kaz Kylheku2015-11-251-5/+8
| | | | | | * share/txr/stdlib/struct.tl (sys:defmeth): New function. Reacts to find-struct-type returning nil. (defmeth): Logic moved into function.
* New macro define-accessor.Kaz Kylheku2015-11-253-1/+92
| | | | | | | | | | | * lisplib.c (place_set_entries): New entry to trigger autoloading for define-accessor. * share/txr/stdlib/place.tl (sys:register-simple-accessor): New function. (define-accessor): New macro. * txr.1: Documented define-accessor.
* New functions window-map and window-mappend.Kaz Kylheku2015-11-255-0/+276
| | | | | | | | | | | | | | | | | * args.h (args_set_fill): New inline function. * eval.c (eval_init): Register window-map and window-mappend intrinics. * lib.c (wrap_k, reflect_k): New keyword variables. (calc_win_size): New static function. (window_map_list, window_map_vec): New static functions. (window_map, window_mappend): New functions. (obj_init): Initialize wrap_k and reflect_k. * lib.h (window_map, window_mappend): Declared. * txr.1: Documented window-map and window-mappend
* Bugfix: split and partition functions.Kaz Kylheku2015-11-241-3/+3
| | | | | | | | | | When the index argument is a function and it returns an empty list, the functions behave incorrectly. * lib.c (partition_split_common): Exchange order of two operations. The handling of an empty indices list must be done after testing for and calling the function which can potentially produce that value.
* Bugfix: super returning type rather than supertype.Kaz Kylheku2015-11-231-1/+1
| | | | | | * struct.c (super): Fix regression from Oct 17. When the argument is a struct instance, we must return the supertype, not the type.
* Struct instances now point directly to low level type.Kaz Kylheku2015-11-231-35/+35
| | | | | | | | | | | | | | | | | | | | | | | This change eliminates numerous cast expressions and a pointer chase from some operations, though some, like the struct_type function, end up chasing an extra pointer. * struct.c (struct struct_type): New member, self. (struct struct_inst): Type member changed from val to struct struct_type *. (make_struct_type): Initialize new self member. (super): Obtain type from si->type->self rather than si->type. There appears to be a bug here. (make_struct, lazy_struct_init): Initialize type field with struct pointer rather than type object. Add an assertion which references the type parameter, to prevent the cobj call from garbage collecting type. (copy_struct, clear_struct, replace_struct, reset_struct, (lookup_slot, slot, slotset, struct_type, uslot_fun, umethod_fun, struct_inst_print, struct_inst_mark, struct_inst_equal, struct_inst_hash, struct_inst_equalsub): All updated to new way of referencing type structure and type object.
* Add man or boy test, based on Knuth's Algol 60 code.Kaz Kylheku2015-11-232-0/+69
| | | | | | | | | | Seems like a good regression test case, combining structs, macros, lambdas, recursion, environments and syntactic places. * tests/012/man-or-boy.tl: New file. * tests/012/man-or-boy.expected: Likewise.
* Version 125.txr-125Kaz Kylheku2015-11-206-382/+436
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Combat spurious retention in few more functions.Kaz Kylheku2015-11-201-13/+17
| | | | | | | * lib.c (sub_list, replace_list): Use original list variable instead of copying it to iter. Use gc_hint on list so that the old value doesn't hang around on the stack, while a register copy marches through the list.
* last function becomes generic.Kaz Kylheku2015-11-202-6/+17
| | | | | | * lib.c (last): Handle non-list sequences via sub function. * txr.1: Updated description of last.
* TXR_COMPAT option.Kaz Kylheku2015-11-202-1/+54
| | | | | | | | | * txr.c (txr_main): Implement handling of TXR_COMPAT environment variable. Also, before entering interactive mode, if compatibility has been set via TXR_COMPAT, emit an informative message about this. * txr.1: Documented TXR_COMPAT.
* New equality substitution.Kaz Kylheku2015-11-206-34/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the equal method is defined for structs, its return value is used in their place for hashing and comparison. * eval.h (eq_s, eql_s, equal_s): Declared. * hash.c (equal_hash): If a COBJ defines an equalsub function, we call it. If it returns non-nil, we take the object in its place and recurse. * lib.c (equal): Refactored to support equality substitution. (less): Support equality substitution. * lib.h (cobj_ops): New function pointer member, equalsub. Only struct instances define this, currently. (cobj_ops_init): Add null entry to initializer for equalsub. (cobj_ops_init_ex): New initialiation macro for situations when the equalsub member must be provided. * struct.c (struct struct_type): new member eqmslot. (make_struct_type): Initialize emslot to zero. (static_slot_set, static_slot_ensure): If eqmslot is -1, indicating positive knowledge that there is no equal method static slot, we must invalidate that with a zero: it is no longer known whether there is or isn't such a slot. (get_equal_method, struct_inst_equalsub): New static functions. (struct_inst_ops): Initialize the equalsub member using new cobj_ops_init_ex macro. * txr.1: Document equality substitution.
* Fix buggy less function.Kaz Kylheku2015-11-201-32/+38
| | | | | | | | | | | | | | | | | | | Allowing rankings among types which documentation says are not comparable. * lib.c (enum less_handling): New enum. (less_tab): Elements are values of the less_handling enum. (less_tab_init): Entries are renumbered. Everything that was given precedence 5 or higher is now zero: not comparable. Precedences 0 to 4 remap to 1 to 5. less_tab is populated differently, since there are four values now. If either the left or right type has 0 precedence, the value is less_cannot: comparison is not possible. (less): Only a less_tab value of less_compare now passes control through to the switch statement. The less_cannot value shortcuts to a cannot compare error. Types that cannot occur in the switch now are removed, and a default case goes to internal error.
* Fix type hole in equal function w.r.t. COBJ.Kaz Kylheku2015-11-201-1/+1
| | | | | | | | * lib.c (equal): We cannot pass both arguments to the left object's equal function just because both arguments are COBJ. We must make sure they are using the same operations. The equal functions blindly assume that both arguments are objects of the same type, and cast the pointers.
* Introducing lazy structs.Kaz Kylheku2015-11-204-3/+182
| | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (lnew): New macro. * struct.c (struct_type): Turn id into a bitfield one bit smaller than cnum. New Boolean bitfield lazy. (struct_init): Register make-lazy-struct intrinsic. (make_struct): Initialize lazy bitfield to zero. (lazy_struct_init, check_init_lazy_struct): New static functions. (make_lazy_struct): New function. (copy_struct, clear_struct, replace_struct, reset_struct, lookup_slot, struct_inst_equal, struct_inst_hash): Call check_init_lazy_struct on all structures involved. (lookup_slot): Call check_init_lazy_struct. (struct_inst_mark): If the struct is lazy, it has one instance slot which must be marked, holding the argfun function passed into make_lazy_struct. * struct.h (make_lazy_struct): Declared. * txr.1: Documented lnew and make-lazy-struct.
* @(next) takes Lisp expression as source now.Kaz Kylheku2015-11-202-3/+36
| | | | | | | | | | | * match.c (v_next): Evaluate the source expression as TXR Lisp, unless it is meta-expression or meta-variable, or the compatibility option is set to 124 or lower. In those cases treat it as an expression of the TXR Pattern * txr.1: Updated documentation of @(next) and all relevant examples of @(next) everywhere. Added compatibility notes.
* Renaming html filters to get rid of underscore.Kaz Kylheku2015-11-202-27/+31
| | | | | | | | | | | | | | | | | * filter.c (to_html_k, from_html_k, to_html_relaxed_k): Variables removed. (tohtml_k, tohtml_star_k, fromhtml_k): New keyword symbol variables. (to_html_table): Array renamed to tohtml_table. (to_html_relaxed_table): Renamed to tohtml_star_table. (from_html_table): Renamed to fromhtml_table. (html_encode): Refers to tohtml_k. (html_encode_star): Refers to tohtml_star_k. (html_decode): Refers to fromhtml_k. (filter_init): Initialize new symbol variables. Remove old registrations. Register filters under old names too. * txr.1: Document new names.
* New :to_html_relaxed filter and html-encode*.Kaz Kylheku2015-11-202-1/+36
| | | | | | | | | | | * filter.c (to_html_relaxed_k): New keyword symbol variable. (to_html_relaxed_table): New static array. (html_encode_star): New static function. (filter_init): Initialize new symbol variable. Register new filter. Register html-encode* function. * txr.1: Documented :to_html_relaxed filter and html-encode* function.
* Filtering to HTML should include ' -> '.Kaz Kylheku2015-11-201-0/+1
| | | | * filter.c (to_html_table): Add entry for apostrophe.
* @(rep) as shorthand for @(coll :vars nil).Kaz Kylheku2015-11-203-5/+41
| | | | | | | | | | | | | * match.c (h_coll): Check for rep symbol, and handle similarly to v_coll. Use symbol in error message. (dir_tables_init): Bind rep symbol to h_coll. * parser.y (elems): Don't generate rep_elem phrase structure for the sake of catching "rep outside of output"; this production now conflicts with the intent to allow this. (elem): Add various REP productions which clones of COLL. * txr.1: Documented new @(rep) usage.
* Use symbol in diagnostics in collect.Kaz Kylheku2015-11-201-9/+9
| | | | | * match.c (v_collect): Don't use hard-coded "collect" in diagnostics because the symbol can be repeat.
* Address spurious retention across library.Kaz Kylheku2015-11-201-17/+95
| | | | | | | | | | | * lib.c (lazy_conses, term, nthcdr, memq, memql, memqual, member, member_if, remq, remql, remqual, remove_if, keep_if, countqual, countql, countq, count_if, some_satisfy, all_satisfy, none_satisfy, proper_listp, length_list, getplist, do_and, do_or, mappend, find, find_if, posqual, posql, posq, pos, pos_if): Use gc_hint on list parameter. (find_max, pos_max, in, search_list, where): Restructure so that list parameter is used as iterator. Use gc_hint on it.
* Combat spurious retention in args handling code.Kaz Kylheku2015-11-202-3/+6
| | | | | | | | | * args.c (args_normalize): Zap the argument in the array when moving it over to the list. * args.h (args_atz): When zapping the argument in the list, zap the actual car field, rather than the list itself. It seems there is a copy of the list somewhere, so zapping it is not effective.
* Combat spurious retention in mapdo.Kaz Kylheku2015-11-201-0/+2
| | | | | | * lib.c (mapdo): gc_hint the list variable so that the list march isn't entirely optimized into a register, leaving a pointer to the top of the list on the stack.
* Useful debugging function for spurious retention.Kaz Kylheku2015-11-202-0/+13
| | | | | | * gc.c (gc_report_copies): New function * gc.h (gc_report_copies): Declared.
* Provide butlast function.Kaz Kylheku2015-11-204-0/+31
| | | | | | | | | | * eval.c (eval_init): Registered butlast intrinsic. * lib.c (butlast): New function. * lib.h (butlast): Declared. * txr.1: Documented butlast.
* Functors: structs callable as functions.Kaz Kylheku2015-11-202-0/+33
| | | | | | | * lib.c (generic_funcall): If an object is used as a function, get its lambda method and call that. * txr.1: Document functors.
* New uslot function and usl macro.Kaz Kylheku2015-11-205-1/+75
| | | | | | | | | | | | | | * struct.c (struct_init): Register uslot intrinsic function. (uslot_fun): New static function. (uslot): New function. * struct.h (uslot): Declared. * share/txr/stdlib/struct.tl (usl): New macro. * lisplib.c (struct_set_entries): Add usl macro. * txr.1: Documented uslot and usl.