summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Use tnil instead of if2 in arithmetic predicates.Kaz Kylheku2018-12-131-9/+9
| | | | | * arith.c (zerop, plusp, minusp): style: if2(expr, t) should be using tnil(expr).
* plusp: wrong name in error message.Kaz Kylheku2018-12-131-1/+1
| | | | * arith.c (plusp): plusp wrongly reports itself as zerop.
* configure: extend some config variable descriptions.Kaz Kylheku2018-12-121-2/+11
| | | | | | | * configure: Add some help text for variables controllinig the compiler command. Mention that CFLAGS and LDFLAGS are honored from the environment or make command line on top of any of the flags settable here.
* Turn off stack protector gcc option.Kaz Kylheku2018-12-121-1/+1
| | | | | | | * configure (opt_flags): Add -fno-stack-protector to disable this feature that is on by default in some toolchains/distros. As a result, I'm seeing an over 5% VM speedup on a loop benchmark.
* bugfix: LDFLAGS not pulled in.Kaz Kylheku2018-12-121-1/+1
| | | | | * Makefile (TXR_LDFLAGS): Fix use of wrong assignment operator which clobbers the previous assignment of $(LDFLAGS).
* Eliminate various unneeded header inclusions.Kaz Kylheku2018-12-124-7/+0
| | | | | | | | | | * hash.c: Don't include "cadr.h". * stream.c: Don't include "struct.h". * strudel.c: No <syslog.h>, ALLOCA_H, "args.h" or "utf8.h". * vm.c: No "hash.h".
* Drastically reduce inclusion of <dirent.h>.Kaz Kylheku2018-12-1125-25/+1
| | | | | | | | | | | | | | | | | | | The <dirent.h> header is included all over the place because it is needed by a single declaration in stream.h. That declaration is for a function that is only called within stream.c, so we make it internal. Now only stream.c has to include <dirent.h>. * buf.c, debug.c, eval.c, ffi.c, filter.c, gc.c, gencadr.txr, hash.c, lib.c, lisplib.c, match.c, parser.c, regex.c, socket.c, struct.c, strudel.c, sysif.c, syslog.c, termios.c, txr.c, unwind.c, vm.c: Remove #include <dirent.h>. * cadr.c: Regenerated. * stream.c (make_dir_stream): Make external function static. * stream.h (make_dir_stream): Declaration updated.
* Version 203.txr-203Kaz Kylheku2018-11-296-593/+611
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: bad formatting under --noninteractiveKaz Kylheku2018-11-281-1/+3
| | | | * txr.1: Fix .code macro occurring in middle of line.
* New range testing functions.Kaz Kylheku2018-11-274-0/+76
| | | | | | | | | | | * eval.c (eval_init): Register in-range and in-range* intrinsics. * lib.c (in_range, in_range_star): New functions. * lib.h (in_range, in_range_star): Declared. * txr.1: Documented.
* case macros: bugfixes for evaluated keys.Kaz Kylheku2018-11-271-5/+5
| | | | | | | | | * eval.c: Fix incorrect treatment of cases like (caseql* ((a b) ...)). The check for evaluation must come before we do the keys = car(keys) transformation. Also, hash_keys must be updated to the evaluated keys, otherwise if the hash table optimization is used, the table will contain the original expressions as the keys, not their values.
* doc: caseql* macro expands cases in global envKaz Kylheku2018-11-271-1/+1
| | | | | | * txr.1: Use the correct term "global environment" rather than "dynamic environment" to desribe the scope in which caseq*, caseql* and casequal* expand the key forms.
* doc: avoid "empty lexical environment".Kaz Kylheku2018-11-271-4/+5
| | | | | | | | | * txr.1: Replace the term "empty lexical environment" with "global environment" in a few places. In one case, it is removed, and the surrounding wording is adjusted. The "empty lexical environment" term is poor because the situations which it describes retain visibility of the "global lexical" variables.
* case macros: stricter syntactic check.Kaz Kylheku2018-11-271-0/+3
| | | | * eval.c (me_case): Throw error if the test form is missing.
* case macros: bugfix empty case.Kaz Kylheku2018-11-271-2/+3
| | | | | | | | | | * eval.c (me_case): When there are no keys, then it is logically true that all keys are integer, and the hash table logic kicks in. The minkey and maxkey variables are supposed to be calculated as zero in that case, but the empty test is bungled since nkeys doesn't test false when it is zero. We end up with minkey and maxkey containing nil which get passed to the minus function. And so, here we fix the empty test.
* doc: clarify pretty printing.Kaz Kylheku2018-11-251-3/+34
| | | | | * txr.1: adding more details to description of the effect of pretty printing.
* print: keep colon in keyword symsKaz Kylheku2018-11-252-2/+14
| | | | | | | | * lib.c (obj_print_impl): Always include leading colon when printing keyword symbols, regardless of pretty flag. Subject to backward compatibility. * txr.1: Compat note added.
* doc: refresh documentation of make-lazy-consKaz Kylheku2018-11-251-8/+34
| | | | | | * txr.1: Documentation of make-lazy-cons revised with important clarifications and details, and removal of some overly informal language.
* Streamline logand and logior slightly.Kaz Kylheku2018-11-251-18/+4
| | | | | | | | * arith.c (logand, logior): Remove wasteful zerop tests which involve a type check. Also don't check for a == b equivalence in CHR and NUM cases; this is a rare case that just adds to the cycles and instruction count. Blindly copying and pasting this code is what led to the bug in logxor.
* logxor: fix seriously broken function.Kaz Kylheku2018-11-254-1/+53
| | | | | | | | | | | | | Reported by Guillaume le Vaillant. * arith.c (logxor): Fix broken behavior when the arguments are the same nonzero fixnum, or the same bignum object. (logxor_old): New function: verbatim copy of previous logxor. * eval.c (eval_init): Register logxor intrinsic to the broken function if compatibility is 202 or less. * txr.1: Compat note added.
* vm: some optimizations.Kaz Kylheku2018-11-221-11/+27
| | | | | | | | | | | | * vm.c (vm_getz): Manual CSE: calculate address of location, then conditionally set to zero. (vm_set_nil_error): New static function. (vm_set, vm_sm_set): Call zero-argument vm_set_nil_error instead of three_argument uw_throwf. (vm_stab_slowpath): New function. (vm_stab): Function marked inline. The slow path when the binding is not cached goes through vm_stab_slowpath which is not inlined.
* Version 202.txr-202Kaz Kylheku2018-11-226-276/+308
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: clarify delimited continuation compiled semanticsKaz Kylheku2018-11-181-10/+30
| | | | | | | | | | * txr.1: Text describing the changes in behavior, under delmited continuations, of compiled code that mutates variables seemed unclear; it is revised. Also, in the section that discusses compiled versus interpreted differences under Lisp Compilation, a paragraph is added mentioning delimited continuations, referring the reader to this detailed section.
* doc: move functionpKaz Kylheku2018-11-171-14/+14
| | | | | * txr.1: functionp belongs under Functions, not Global Environment.
* doc: use bulleted list under copy.Kaz Kylheku2018-11-171-56/+29
| | | | | * txr.1: Present the type cases of the copy function using a more compact and visually appealing bulleted list.
* copy: call copy-fun for functions.Kaz Kylheku2018-11-172-0/+8
| | | | | | * lib.c (copy): Handle FUN type through copy_fun. * txr.1: Documented.
* compiler: use binary versions of common math functions.Kaz Kylheku2018-11-162-0/+28
| | | | | | | | | | | | | | | * arith.c (arith_init): Register functions in the sys package: b<, b>, b<=, b=, b+, b-, b*, b/ and neg. * share/txr/stdlib/compiler.tl (%nary-ops%, %bin-ops%, %bin-op%): New global variables. (compiler comp-fun-form): Transform two-argument calls to any of the variadic functions in %nary-ops% functions into calls to their binary counterpart. These calls are faster, since they bypass the wrapper which deals with the variable argument list. Also, we detect unary - and map it to the new sys:neg function, and reduce the one-argument cases of certain functions to noops.
* vm: provide special case call entry points.Kaz Kylheku2018-11-163-14/+112
| | | | | | | | | | | | | | | * lib.c (funcall, funcall1, funcall2, funcall3, funcall4): Use vm_funcall, vm_funcall1, vm_funcall2, vm_funcall3, and vm_funcall4, respectively instead of the general vm_execute_closure. Also, missing argument count check added in funcall. * vm.c (vm_funcall_common): New macro. (vm_funcall, vm_funcall1, vm_funcall2, vm_funcall3, vm_funcall4): New functions. * vm.h (vm_funcall, vm_funcall1, vm_funcall2, vm_funcall3, vm_funcall4): Declared.
* vm: use faster funcall functions in vm_gcall.Kaz Kylheku2018-11-161-15/+58
| | | | | * vm.c (vm_gcall): For the 0 to 4 argument cases, use funcall, funcall1, ..., funcall4 instead of generic_funcall.
* math: remove redundant type checks from NUM.Kaz Kylheku2018-11-162-118/+122
| | | | | | | | | | | | * arith.c (plus, minus, neg, abso, signum, mul, trunc, mod, floordiv, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt, exptmod, isqrt, gcd, flo_int, logand, logior, logxor, comp_trunc, lognot, logtrunc, sign_extend, ash, bit, logcount, tofloat, toint, width, poly, rpoly): Use the unchecked c_n rather than c_num on quantities that are known to be of NUM and CHR type. * lib.h (c_n): New inline function.
* args: remove unused macro.Kaz Kylheku2018-11-141-4/+0
| | | | * args.h (args_alloc): Macro removed.
* compile: handle functions that have environments.Kaz Kylheku2018-11-133-2/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, the compile function can handle interpreted function objects that have captured environments. For instance, if the following expression is evaluated (let ((counter 0)) (labels ((bm () (bump)) (bump () (inc counter))) (lambda () (bm)))) then a function object emerges. We can now feed this function object to the compile function; the environment will now be handled. Of course, the above expression is already compileable; compile-toplevel handles it and so does the file compiler. This patch allows the expression to be interpreted and then the function object to be compiled, without access to the surrounding expression. The compiled function will contain a compiled version of the environment, carrying compiled versions of the captured variables and their contents. * eval.c (env_vbindings, env_fbindings, env_next): New static functions. (eval_init): Register env-vbinding, env-fbindings and env-next intrinsics. * share/txr/stdlib/compiler.tl (sys:env-to-let): New function. (usr:compile): Wrap the interpreted lambda terms with let bindings carefully reconstructed from their captured environments. * txr.1: Documented new intrinsic functions.
* copy-fun: duplicate a function, with own environment.Kaz Kylheku2018-11-137-0/+97
| | | | | | | | | | | | | | | | | * eval.c (deep_copy_env): New function. (eval_init): Register copy-fun intrinsic. * eval.h (deep_copy_env): Declared. * lib.c (copy_fun): New function. * lib.h (copy_fun): Declared. * vm.c (vm_copy_closure): New function. * vm.h (vm_copy_closure): Declared. * txr.1: Documented copy-fun.
* regex: relocate unlikely case after other tests.Kaz Kylheku2018-11-121-3/+3
| | | | | | * regex.c (reg_derivative): When classifying the regex's operator, don't check for vanishingly unlikely internal error cases first; that should be done at the end.
* doc: corrections under Referencing DotKaz Kylheku2018-11-111-6/+9
| | | | | * txr.1: Don't start sentence with And. Revise and correct description of associativity of referencing dot.
* doc: changes to introKaz Kylheku2018-11-111-27/+39
| | | | | | * txr.1: Substantially revising introductory paragraphs. Mentioning compiling and stand-alone application deployment. Mention licensing freedom.
* doc: listener suspend doesn't "depend" on job controlKaz Kylheku2018-11-111-2/+6
| | | | | | | * txr.1: Revise wording implying that the Ctrl-Z suspend depends on POSIX job control. Job control is required for it to allow TXR to be foregrounded after it suspends. That is not our problem.
* doc: listener: remove irrelvant historic notesKaz Kylheku2018-11-111-9/+2
| | | | | | * txr.1: In descriptions of multi-line mode, remove notes about behavior changes between TXR 178 and 179. This doesn't affect TXR program and is probably of no interest to anyone.
* doc: fixes under Null Hack description.Kaz Kylheku2018-11-111-9/+11
| | | | | * txr.1: Fix awkward wording about env's dispatch of txr, and references to wrong user name in examples.
* POSIX requires <sys/select.h> for select function.Kaz Kylheku2018-11-092-0/+27
| | | | | | | | | | | | | A patch being applied to TXR in the Void Linux distribution informs me that the Musl library requires this. Traditional Unix put the select materials in <sys/types.h> and <unistd.h>. * configure: Add test for presence of <sys/select.h> and whether that header actually declares select-related declarations and macros. Define HAVE_SYS_SELECT_H in config.h if so. * socket.c: Conditionally include <sys/select.h>.
* gethash_l: C99 fix for Solaris.txr-201Kaz Kylheku2018-11-071-1/+1
| | | | | * hash.c (gethash_l): C99 inline instantiation updated to match new type signature.
* Version 201.Kaz Kylheku2018-11-076-984/+1014
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Better identify functions that misuse COBJ-s and hashes.Kaz Kylheku2018-11-0720-300/+445
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this patch, the cobj_handle, cobj_ops and variants of gethash get an additional argument to identify the caller. Many functions are updated to pass this down. * buf.c (buf_strm): Pass self name to cobj_handle. * eval.c (env_fbind, env_vbind, rt_defvarl, me_case): Pass self name to gethash_c or gethash_e. (load): Pass self name to read_eval_stream and read_compiled_file. (reg_symacro): Pass situation-identifying string to gethash_c. * ffi.c (ffi_type_struct_checked, ffi_closure_struct_checked, ffi_call_desc_checked, uni_struct_checked): Take self name parameter, and pass down to cobj_handle. (ffi_get_type, ffi_get_lisp_type): Take self name and pass down to ffi_type_struct_checked. (union_get_ptr): Take self name and pass to uni_struct_checked. (ffi_union_in, ffi_union_put): Pass self name to union_get_ptr. (ffi_type_compile): Pass self name to ffi_get_lisp_type. (ffi_make_call_desc): Pass self name to ffi_type_struct_checked, ffi_get_type and ffi_call_desc_checked. (ffi_make_closure): Pass self name to ffi_call_desc_checked. (ffi_closure_get_fptr): Take self name, pass to ffi_closure_struct_checked. (ffi_typedef, ffi_size, ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype, ffi_put_into, ffi_put, ffi_in, ffi_get, ffi_out, make_carray): Pass self name to ffi_closure_struct_checked. (carray_struct_checked): Take self name, pass to cobj_handle. (carray_set_length, carray_dup, carray_own, carray_free, carray_type, length_carray, copy_carray, carray_ptr, buf_carray, vec_carray, list_carray, carray_ref, carray_refset, carray_sub, carray_replace, carray_get_common, carray_put_common, unum_carray, num_carray, put_carray, fill_carray): Pass self name to carray_struct_checked. (carray_blank, carray_buf, carray_cptr): Pass self name ffi_type_struct_checked. (carray_pun): Pass self name to carray_struct_checked and ffi_type_struct_checked. (make_union): Pass self name to ffi_type_struct_checked. (union_members, union_get, union_put, union_in, union_out): Pass self name to uni_struct_checked. (make_zstruct, zero_fill, put_obj, get_obj, fill_obj): Pass self-name to ffi_type_struct_checked. * ffi.h (ffi_closure_get_fptr, union_get_ptr): Declarations updated. * filter.c (trie_add): Pass self-name to gethash_l. * hash.c (make_similar_hash, copy_hash, hash_count, get_hash_userdata, set_hash_userdata, hash_begin, hash_next, hash_uni, hash_diff, hash_isec): Pass self name to cobj_handle. (gethash_c, gethash_e): Take self name parameter and pass down to cobj_handle. (gethash_f): Take self parameter and pass down to gethash_e. (gethash, inhash, gethash_n, sethash, pushhash, remhash, clearhash, hash_update_1): Pass self name to gethash_e or gethash_c. * hash.h (gethash_c, gethash_e, gethash_f): Declarations updated. (gethash_l): Take self name, and pass down to gethash_c. * lib.c (class_check): Take self name parameter and use in type mismatch diagnostic. (use_sym, unuse_sym, symbol_needs_prefix, find_symbol, intern, unintern, intern_fallback, unique, in, sel, obj_print_impl, populate_obj_hash, obj_hash_merge): Pass self name to gethash_f or gethash_l. (symbol_visible, obj_init): Pass situation-identifying string to gethash_e. (cobj_handle, cobj_ops): Take self name parameter and pass down to class_check. * lib.h (class_check, cobj_handle, cobj_ops): Declarations updated. * match.c (v_load): Pass self name to read_compiled_file and read_eval_stream. * parser.c (get_parser_impl): Take self name and pass to cobj_handle. (ensure_parser): Pass situation-identifying string to gethash_c. (parser_circ_def): Pass self-name to gethash_c. (lisp_parser_impl): Pass self name to get_parser_impl and class_check. (lisp_parse, nread, iread): Pass self-name to lisp_parser_impl. (read_file_common): Take self name parameter and pass down to get_parser_impl. (read_eval_stream, read_compiled_file): Take self name and pass down to read_file_common. (load_rcfile): Pass situation-identifying string to read_eval_streem. (get_visible_syms): Pass situation-identifying string to gethash_c. (parser_errors, parser_eof): Pass self name to cobj_handle. * parser.h (read_eval_stream, read_compiled_file): Declarations updated. * parser.y (rlset): Pass self name to gethash_c. * rand.c (make_random_state, random_state_get_vec,l random_fixnum, random_float): Pass self name to cobj_handle. * regex.c (regex_source, regex_print, regex_run): Pass self-name to cobj_handle. (regex_machine_init): Take self name param and pass to cobj_handle. (search_regex, match_regex, match_regex_right, regex_prefix_match, read_until_match): Pass self-name to regex_machine_init. * stream.c (stdio_get_fd): Pass self name to cobj_handle. (generic_get_line): Get COBJ operations via unsafe, diret object access rather than cobj_ops. (set_mode_props): Get object handle via unsafe, direct object access. (stream_fd, sock_family, sock_type, sock_peer, set_sock_peer, get_string_from_stream, get_list_from_stream, stream_set_prop, stream_get_prop, close_stream, get_error, get_error_str, clear_error, get_line, get_char, get_byte, unget_char, unget_byte, put_buf, fill_buf, put_string, put_char, put_byte, flush_stream, seek_stream, truncate_stream, get_indent_mode, test_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check, force_break, get_set_ctx, get_ctx): Pass self name to cobj_ops. (make_delegate_stream): Take self name parameter, pass down to cobj_ops. (record_adapter): Pass self name down to make_delegate_stream. (format): Pass self name to class_check. * struct.c (stype_handle): Pass self name to cobj_handle. (make_struct_type): Pass self name to class_check. * txr.c (read_eval_stream_noerr): Take self name parameter, pass to read_eval_stream. (txr_main): Pass istuation-identifying string to read_compiled_file and read_eval_stream_noerr. * unwind.c (revive_cont): Pass self-name to cobj_handle. * vm.c (vm_desc_struct): Take self name parameter, pass to cobj_handle. (vm_desc_nlevels, vm_desc_nregs, vm_desc_bytecode, vm_desc_datavec, vm_desc_symvec, vm_execute_toplevel, vm_execute_closure, vm_closure_entry): Pass self name to vm_desc_struct. (vm_closure_struct): Take self name parameter, pass to cobj_handle.
* lib: remove unused type checking functions.Kaz Kylheku2018-11-072-19/+0
| | | | | | * lib.c (type_check2, type_check3): Functions removed. * lib.h (type_check2, type_check3): Declarations removed.
* Fix wrong uses of ~s for function name string.Kaz Kylheku2018-11-074-18/+18
| | | | | | | | | | | | * ffi.c (make_ffi_type_enum): Use ~a for function name rather than ~s because it's a string which is quoted under ~s. * lib.c (chk_xalloc, string_extend, find_symbol, intern_fallback): Likewise. * stream.c (open_process, run): Likewise. * sysif.c (exec_wrap, setgroups_wrap, dlclose_wrap): Likewise.
* type_check: take function name arg.Kaz Kylheku2018-11-076-56/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * arith.c (flo_int): Pass down name to type_check. * eval.c (copy_env, env_fbind, env_vbind, env_vb_to_fb, func_get_name, lexical_var_p, lexical_fun_p, lexical_lisp1_binding, squash_menv_deleting_range, op_upenv): Pass relevant Lisp function name to type_check. (lookup_global_var, lookup_sym_lisp1, lookup_fun, lookup_mac, lookup_symac, lookup_symac_lisp1): For these widely used functions, pass situational prefix in place of function name. They may get a funtion name argument in the future. * gc.c (gc_finalize): Pass function name to type_check. * lib.c (throw_mismatch): Take function nme argument, incorporate into mesage. (lcons_fun, c_flo, string_extend, symbol_name, symbol_package, get_package, package_name, func_get_form, func_get_env, func_set_env, vec_set_length, length_vec, size_vec, list_vec, lay_str_force, lay_str_force_upto, lazy_str_get_trailing_list, from, too, set_from, set_to): Pass relevant Lisp function name to type_check. (symbol_setname, symbol_visible): Pass indication of internal error into type_check, since this doesn't pertain to any Lisp function being wrong. * lib.h (throw_mismatch): Declaration updated. (type_check): Take new parameter and pass down to throw_mismatch. * signal.c (set_sig_handler): Pass name down to type_check.
* symbol_needs_prefix: take function name argument.Kaz Kylheku2018-11-072-4/+4
| | | | | | | | * lib.c (symbol_needs_prefix): New parameter. (unquote_star_check, obj_print_impl): Pass Lisp function name to symbol_needs_prefix. * lib.h (symbol_needs_prefix): Declaration updated.
* lazy strings: remove two type checks.Kaz Kylheku2018-11-071-2/+0
| | | | | | * lib.c (lazy_str_put, out_lazy_str): The very few calls to these functions already ensure that the object is a lazy string; let's drop the check.
* math: improve error diagnosis.Kaz Kylheku2018-11-076-123/+198
| | | | | | | | | | | | | | | | | | | | | | | | | | More streamlined code, better identification of functions. * arith.c (not_number, not_integer, invalid_ops, invalid_op, divzero): New static functions. (num_to_buffer, bugnum_len, plus, minus, neg, abso, signum, mul, trunc1, mod, floordiv, round1, roundiv, divi, zerop, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt, exptmod, floorf, ceili, sine, cosi, tang, asine, acosi, atang, loga, logten, logtwo, expo, sqroot, int_flo, flo_int, cum_norm_dist, inv_cum_norm): Establish function's Lisp name as self variable. Use new static functions for reporting common errors. Pass function name to new argument of c_flo function. * buf.c (buf_put_float, buf_put_double): Pass function's Lisp name to c_flo function. * ffi.c (ffi_float_put, ffi_double_put): Likewise. * lib.c (c_flo): Takes new argument, name of calling function. * lib.h (c_flo): Declaration updated. * stream.c (formatv): Pass function name to c_flo.
* lib: use type switch in some string functions.Kaz Kylheku2018-11-061-79/+67
| | | | | | * lib.c (length_str, c_str, length_str_gt, length_str_ge, length_str_lt, length_str_le): Streamline code into single switch on the type code of the object.