summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* compiler: stray debug print.Kaz Kylheku2019-04-161-1/+0
| | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-lambda): Stray prinl removed, issued in the rare case when the present flag parameter of an optional parameter is present and is a special var.
* New catch** macro.Kaz Kylheku2019-04-103-2/+44
| | | | | | | | | * lisplib.c (except_set_entries): Autoload for catch** symbol. * share/txr/stdlib/except.tl (catch**): New macro. * txr.1: Document catch** macro, and the desc slot of the catch-frame struct.
* exceptions: allow description field in catch frames.Kaz Kylheku2019-04-108-22/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (op_catch): Extra argument in sys:catch syntax specifies an expression that evaluates to a description field. (expand_catch): Expand the desc expression in sys:catch syntax. * parser.c (read_file_common): Increase acceptance of compiled files from versions 1-4 to 1-5, since we are now marking compiled files with version 5.0 rather than 4.0. * share/txr/stdlib/asm.tl (op-catch catch): Support new argument in the opcode syntax. Turns out we have a spare field in the instruction format which was previously set to zero We can use that for the description. Thus, the instruction set and VM remain backward compatible: old code works. * share/txr/stdlib/compiler.tl (compiler comp-catch): Handle the desc argument introduced into the sys:catch form. We must compile it as an expression, then inject the code into the instruction template, and reference the output register of that code block in the catch instruction. (%tlo-ver%): Bump up the compiled file version to 5.0. * share/txr/stdlib/except.tl (usr:catch, catch*): Add desc argument to generated sys:catch form, specifying it as nil. * unwind.c (desc_s): New symbol variable. (uw_find_frames_impl): Set the desc member of the extracted catch structure from the corresponding field in the catch frame. (uw_late_init): Initialize desc_s with interned symbol. Add desc slot to catch-frame type. * unwind.h (struct uw_catch): New member, desc. (uw_catch_begin_w_desc): New macro. * vm.c (vm_catch): Extract the desc field from the catch instruction, and use uw_catch_begin_w_desc to propagate that to the catch frame.
* debug support: crude debugger removed.Kaz Kylheku2019-04-0911-744/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (debug_depth, debug_quit_s): Variables removed. (step_mode, next_depth, breakpoints, last_command, cols): Static variables removed. (debug_check): C99 inline instantiation removed. (help, show_bindings): Static functions removed. (debug): Function removed. (debug_set_state): Now takes one int argument, returns int. It's anticipated that the new debug system will have a simple on-off switch; there won't be a debug_depth hack. (debug_restore_state): Function removed. (debug_init): Emptied. * debug.h (debug_depth, debug_state_t): Declarations removed. (debug_enter, debug_leave, debug_return): Macros removed. (debug_check): Inline function removed. (debug_set_state): Declaration updated. (debug_restore_state): Declaration removed. (debug_frame, debug_end): Macros removed. * eval.c (do_eval, me_interp_macro): Debugging support scrubbed. * lisplib.c (lisplib_try_load): Adapt to debug_set_state interface change. * match.c (h_fun, do_match_line, v_fun, match_files, match_fun): Debugging support scrubbed. * parser.y (parse_once): Adapt to debug_set_state interface change. * protsym.c: Regenerated. * signal.h (debug_depth): Declaration removed. (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST): Macros removed. (EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): Reduced to unconditionally empty definitions for future use. * unwind.c (uw_push_debug): Function removed. * unwind.h (uw_frtype_t): UW_DBG enum member removed. (struct uw_debug): struct declaration removed. (union uw_frame): db member removed. (uw_push_debug): Declaration removed. * txr.1: Debugger doc removed.
* protsym: missing update.Kaz Kylheku2019-04-091-210/+208
| | | | | | | | * protsym.c: Regenerated. This eliminates the duplicate listing of bit_s, which was defined twice. That double definition was caught by the C++ compiler and fixed prior to the 215 release, but the change wasn't picked up in protsym.c.
* repl: groundwork for recursive listener invocation.Kaz Kylheku2019-04-083-9/+19
| | | | | | | | | | | | | | | | | * parser.c (lino_ctx, repl_level): New static variable. (repl): Increment repl_level on entry and decrement on exit. On the initial entry, allocate the lino_t object, storing it in the new static variable. Free it on outermost exit. The number of > characters in the prompt indicates the nesting level. The function now takes an environment parameter, which is applied to the evaluation of the input form. The intent is to be able to supply symbol macros which expand to function calls implementing debugger commands. (parser_init): Register sys:repl intrinsic. * parser.h (repl): Declaration updated. * txr.c (txr_main): Pass nil environment parameter to repl
* doc: update debug session.Kaz Kylheku2019-04-071-59/+147
| | | | | * txr.1: Repeated debug session with new version of the navytime.txr script, and the latest TXR.
* doc: fix overlong lines.Kaz Kylheku2019-04-061-19/+43
| | | | | | * txr.1: Reformat lines in .verb blocks that are wider than 79 columns for the sake of reading the manual with man on an 80 column terminal.
* doc: split .cblk into .verb and .monoKaz Kylheku2019-04-062-2093/+2119
| | | | | | | | | | | | | | | * txr.1 (.cblk, .cble): Macros renamed to .mono and .onom respectively. (.verb, .brev): New macros. These are like .cblk and .cble but instead of just switching the font, they switch in and out of non-formatting mode also with .nf/.fi. Everywhere in the document, .cblk/.cble used for just font changes are replaced with .mono/.onom, and those instances used for preformatted code blocks are replaced with .verb/.brev. * checkman.txr (check-cblk): Removed. (check-mono, check-verb): New pattern functions.
* unwind: rename env frames.Kaz Kylheku2019-04-063-36/+36
| | | | | | | | | | | | | | | | | | | | | | Unwind frames of type ENV exist for the sake of the pattern language. Let's rename them accordingly. * match.c (tleval, tleval_progn, h_fun, tx_subst_vars, v_bind, v_output, v_filter, v_fun): Occurrences of the macros uw_env_begin and uw_env_end are renamed. * unwind.c (uw_env_stack): Renamed to uw_menv_stack. (uw_unwind_to_exit_point, uw_abscond_to_exit_point, uw_find_env, uw_pop_frame, revive_cont): Follow rename of UW_ENV to UW_MENV and uw_env_stack to uw_menv_stack. (uw_push_env): Renamed to uw_push_match_env, and updated to follow renames. * unwind.h (enum uw_frtype, uw_frtype_t): UW_ENV renamed to UW_MENV. (uw_push_env): Renamed to uw_push_match_env. (uw_env_begin, uw_env_end): Renamed to uw_match_env_begin an uw_match_env_end.
* New function: cptr-size-hint.Kaz Kylheku2019-04-064-0/+29
| | | | | | | | | | * eval.c (eval_init): Register cptr-size-hint intrinsic. * lib.c (cptr_size_hint): New function. * lib.h (cptr_size_hint): Declared. * txr.1: Documented.
* doc: forgotten cptr functions.Kaz Kylheku2019-04-061-0/+29
| | | | * txr.1: Document cptrp and cptr-type.
* mpi: use integer math for radix length.Kaz Kylheku2019-04-054-59/+42
| | | | | | | | | | | | | | | | | | | | * mpi/logtab.h: Regenerated. (s_logv_2): Now table of scaled integers. (MP_LOG_SCALE): New constant. * mpi/make-logtab.txr (scale, type): New variables. Generate integer table with log2 values scaled by the scale factor, rounded up. * mpi/config.h (MP_LOGTAB): Removed. We always use the table. * mpi/mpi.c: Unconditionally include logtab.h. (LOG_V_2): Macro removed. (s_mp_outlen): Rewritten using scaled integer math. Overflow is avoided by splitting the input into a part that is an exact multiple of the scale factor, and a remaining part. Only the remaining part need be multiplied by a value from the table before dividing by the scale factor.
* @(output): bugfix: lazy evaluation doesn't work.Kaz Kylheku2019-04-051-4/+15
| | | | | | | | | | | | | | | In an @(output), if we reference a variable bound to a lazy list, and the generation of that logic references TXR pattern variables, things break: the lazy list's code doesn't see the binding. This is because the lazy list is forced by some logic that doesn't establish the proper environment for that evaluation. Inside a @(repeat), the do_output function measures the lengths of lists emanating from variables, and that has the effect of forcing the lazy lists. * match.c (v_output): Just set up the dynamic environment around the entire function, so that any Lisp evaluation that occurs is happening as if it were via tleval.
* compiler: better shared test for sys:switch.Kaz Kylheku2019-04-051-1/+6
| | | | | | | | | * share/txr/stdlib/compiler.tl (compiler comp-switch): The shared test here is both inaccurate and O(n^2). It tests that all the remaining branches of the code are tails of the first branch. However, this is not strict enough: we need to also test that the tails are in their order of appearance. We can do that in O(n) time.
* tagbody: code replication bug.Kaz Kylheku2019-04-051-20/+14
| | | | | | | | | | | | | | | tagbody translates to a loop around a sys:switch special form. The compiler recognizes substructure sharing among the branches of the the sys:switch code and de-duplicates the generated assembly code accordingly. Unfortunately, the expander for sys:switch has a bug which spoils the substructure sharing. * eval.c (expand_forms_ss): We must process the incoming form list itself into the hash, not just that list's cdr. Onthe other hand, there is no need to hash the cars of the forms list (the forms themselves), so the code simplifies quite a bit.
* genvim: treatment of comments.Kaz Kylheku2019-04-041-0/+2
| | | | | * genvim.txr (comments): new variable. Generate "set comments" command for TXR and TXR Lisp.
* Replace Perl program that came with MPI.Kaz Kylheku2019-04-012-32/+26
| | | | | | * mpi/make-logtab: File removed. * mpi/make-logtab.txr: New file.
* Version 215.txr-215Kaz Kylheku2019-03-307-505/+551
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* arith: missing alloca.Kaz Kylheku2019-03-301-0/+1
| | | | | | * arith.c: we need to include "alloca.h" since we have moved some functions into here from lib.c which use "args.h" macros. This shows up on Cygwin and some other platforms.
* c++ maintenance: multiple defs of mod_s and bit_s.Kaz Kylheku2019-03-303-2/+4
| | | | | | | | | * arith.h (mod_s, bit_s): Add extern declarations. * ffi.c (bit_s): Remove definition. * match.c (mod_s): Remove definition. Include "arith.h" to obtain declaration of mod_s.
* u-d-arithmetic: proper treatment of ceil & round.Kaz Kylheku2019-03-303-40/+35
| | | | | | | | | | | | | | | * arith.c (r_ceil_s, r_round_s): New symbol variables. (ceildiv, roundiv): Route binary cases involving struts directly to binary methods so the object is responsible for the complete implementation. (arith_init): Initialize r_ceil_s and r_round_s. * tests/016/ud-arith.tl (numbase): Binary methods added for ceil and round. Test cases added. * txr.1: Descriptions for binary ceil and round methods added; Notes about non-existence of binary methods removed from unary ceil and round removed.
* u-d-arithmetic: forgotten dispatch cases.Kaz Kylheku2019-03-301-0/+20
| | | | | * arith.c (plus, minus, mul, mod, floordiv): Dispatch reverse operaton for PTR/COBJ combination.
* Tests for user-defined arithmetic and fixes.Kaz Kylheku2019-03-304-33/+170
| | | | | | | | | | | | | | | | | | | | | | | * tests/016/ud-arith.expected b/tests/016/ud-arith.tl: New file. * tests/016/ud-arith.expected b/tests/016/ud-arith.expected: New file. * arith.c (divi): Bugfix: wrong argument tested for being a COBJ. (logtrunc): Fix incorrect method call: calling r-logtrunc-s for the object-in-left-position case. (sign_extend): Fix semantics not following documentation: dispatch method with original arguments. (divv): When there is just one argument, take advantage of the hitherto unused unary case of divi rather than giving it both arguments. The object dispatch is in that unary case, so we need it now. (arith_init): Fix wrong name of r_lognot_s symbol. * txr.1: Fix atan2 being documented as atan. Fix misspelling of r-lognot as lognot-r.
* New feature: user-defined math.Kaz Kylheku2019-03-302-135/+1041
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the library now accepts struct objects as arguments, relying on them to implement methods. * arith.c (minus_s, inv_minus_s, neg_s, abs_s, signum_s, mul_s, div_s, recip_s, inv_div_s, trunc1_s, trunc_s, r_trunc_s, mod_s, r_mod_s, zerop_s, plusp_s, minusp_s, evenp_s, oddp_s, gt_s, lt_s, ge_s, le_s, numeq_s, expt_s, r_expt_s, exptmod_s, isqrt_s, square_s, floor_s, floor1_s, r_floor_s, ceil_s, ceil1_s, round_s, round1_s, sin_s, cos_s, tan_s, asin_s, acos_s, atan_s, atan2_s, r_atan2_s, log_s, log2_s, log10_s, exp_s, sqrt_s, logand_s, logior_s, logxor_s, lognot1_s, lognot_s, r_lognot_s, logtrunc_s, r_logtrunc_s, sign_extend_s, ash_s, bit_s, width_s, logcount_s): New symbol variables. (not_struct_error, method_error, do_unary_method, do_binary_method, do_ternary_method): New static functions. (plus, minus, neg, abso, signum, mul, trunc1, trunc, mod, floordiv, round1, roundiv, divi, zerop, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt, exptmod, isqrt, square, floorf, ceili, since, cosi, tang, asine, atang, atang2, loga, logten, logtwo, expo, sqroot, logand, logior, logxor, comp_trunc, lognot, sign_extend, ash, bit, logcount, width, bits, unary_num, unary_arith): Support struct arguments. (plusv, minusv, mulv, divv, sumv, prodv, gtv, ltv, gev, lev, numeqv, exptv, logandv, logiorv): Use symbol for self instead of string lit. (arith_init): Initialize new symbol variables. Replace existing intern calls in function registrations with references to some of these symbol variables. * txr.1: Documented.
* doc: umax is misdocumented.Kaz Kylheku2019-03-261-6/+60
| | | | | | | * txr.1: umask returns the current value, not the value t. The argument is optional, for just returning the current value, which is done via a destructive trick that we should document. Mention all the permission constants also.
* listener: ensure history and temp files are rw-------.Kaz Kylheku2019-03-261-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | For security, the temporary files used by the "edit in external editor" feature of the listener, as well as the listener history file, should be readable and writable only to the owner. This relates to Debian bug 832460 against the Linenoise library: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=832460 In the TXR fork of the linenoise library, since we have an OS abstraction invoked by callback functions, we fix this entirely outside of linenoise. I don't agree with the upstream approach of fiddling with the umask and doing a chmod on the path. Since we are truncating and overwriting the file, all we have to do is, before writing any data, fchmod it to the required permissions. * parser.c (lino_open): If the file is being open for overwriting, then let's set its permissions so that it's readable and writable for the user only.
* plus: missing breaks.Kaz Kylheku2019-03-251-0/+2
| | | | | | | | | * arith.c (plus): Add missing break statements to two switch cases. One is at the end, where it is not strictly necessary. The other omission is harmless also and may have been deliberate, though not commented by a /* fallthrough */. The other functions with this same pattern, namely minus, has the breaks.
* Move numeric functions from lib.c to arith.cKaz Kylheku2019-03-253-441/+445
| | | | | | | | | | | | | | | * arith.c, lib.c (num, c_num, c_fixnum, bad_float, flo, c_flo, fixnump, bignump, integerp, floatp, numberp nary_op, nary_simple_op, plusv, minusv, mulv, divv, logandv, logiorv, gtv, ltv, gev, lev, numeqv, numneqv, sumv, prod, exptv, gcdv, lcmv): Function definitions moved from lib.c to arith.c. (nary_op_keyfun, unary_num, unary_arith, unary_int, sumv, prodv, rexpt, abso_self): Static functions moved from libmoved from lib.c to arith.c. (max): New macro in arith.c. (arith_init): Registrations moved from eval.c. * eval.c (eval_init): Registrations moved to arith.c
* Register arithmetic functions in arith module.Kaz Kylheku2019-03-252-47/+50
| | | | | | | | * arith.c (plus_s): Definition moved here. (arith_init): Register numerous math intrinsics here. * eval.c (plus_s): Definition removed. (eval_init): Numerous math function registrations removed.
* Version 214.txr-214Kaz Kylheku2019-03-227-621/+664
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* float: fix syntax error involving fplassify.Kaz Kylheku2019-03-221-1/+1
| | | | | | * lib.c (bad_float): Add missing parentheses around controlling expression of switch statement. This worked on glibc because it's a macro which expands to parentheses.
* doc: clarifications under lambda.Kaz Kylheku2019-03-221-1/+21
| | | | | | | | | * txr.1: Make it clearer that the default expression of an optional parameter is only evaluated when required. Document that t, nil and keyword symbols can't be used as parameters, and that duplicates symbols are unspecified, the situation being diagnosed by the compiler but ignored by the interpreter.
* doc: update let/let* doc.Kaz Kylheku2019-03-221-14/+117
| | | | | | * txr.1: specification of let and let* is substantially revised for clarity, and behavior of duplicate symbols, and special variables.
* take-until: rewrite with seq_info; elide cons.Kaz Kylheku2019-03-201-16/+13
| | | | | | | | | | * lib.c (take_until_list_fun): Renamed to lazy_take_until_list_fun. (lazy_take_until_list_fun, take_until): take_until upgraded to use seq_info to classify sequence. In the lazy list case, the state cons is elided; the predicate function is passed as the function environment, and the key function and list being traversed are propagated via the lazy cons car and cdr.
* take: rewrite with seq_info; elide cons.Kaz Kylheku2019-03-202-32/+32
| | | | | | | | | | | | | * lib.c (take_list_fun, take_while_list_fun): Renamed to lazy_take_list_fun and lazy_take_while_list_fun respectively. (lazy_take_list_fun, take): take upgraded to use seq_info to classify sequence. In the lazy list case, the state cons is elided; the list is passed as the function environment, and the remaining count is propagated in the lazy cons's car field. (lazy_take_while_list_fun, take_while): Similar changes. * txr.1: Fixed accidental reference to drop function in the documentation for the take function.
* interpose: eliminate state cons.Kaz Kylheku2019-03-181-9/+5
| | | | | * lib.c (lazy_interpose_func, lazy_interpose): Pass list in car of lcons, and separator as function env.
* partition*: optimization.Kaz Kylheku2019-03-181-14/+8
| | | | | | * lib.c (partition_star_func, partition_star): Eliminate state cons. Eliminate wasteful cons updating and destructuring in loop.
* doc: clarify split/partition difference.Kaz Kylheku2019-03-181-0/+8
| | | | | * txr.1: Under in split doc, add a sentence highlighting the difference between split and partition.
* partition, split, split*: eliminate state conses.Kaz Kylheku2019-03-181-30/+31
| | | | | | * lib.c (partition_func, split_func, split_star_func, partition_split_common): Store three context elements in function's env, and lcons car/cdr.
* partition-by: eliminate state conses.Kaz Kylheku2019-03-171-12/+7
| | | | | | * lib.c (partition_by_func, partition_by): Store the three context items in the function's env, and the lcons car and cdr, instead of allocating a two-cons list stored in the env.
* tuples: eliminate state conses.Kaz Kylheku2019-03-151-8/+6
| | | | | | * lib.c (tuples_func, tuples): Store the three context items in the function's env, and the lcons car and cdr, instead of allocating a two-cons list stored in the env.
* flatcar*: eliminate state cons.Kaz Kylheku2019-03-151-5/+5
| | | | | | | * lib.c (lazy_flatcar_func, lazy_flatcar): Here, the state information consists of just one value. We just make that value itself the function's env, and mutate that env as needed.
* flatten*: use lcons for threading state.Kaz Kylheku2019-03-151-5/+6
| | | | | | | * lib.c (lazy_flatten_func, lazy_flatten): Do not allocate a cons to hold the traversal state. In fact, the environment of the function is not used at all; the lcons car and cdr are used to propagate the state.
* append*: save a bit of memory.Kaz Kylheku2019-03-141-9/+8
| | | | | | | | * lib.c (lazy_appendv_func, lazy_appendv): Do not allocate a cons cell for maintaining the state. Use the function environment for one of the two state values, and thread the other state value through the initial car contents of each lazy cons cell.
* New unchecked setter for function environment.Kaz Kylheku2019-03-142-0/+7
| | | | | | | * lib.c (us_func_set_env): New function: func_set_env without the type check. * lib.h (us_func_set_env): Declared.
* doc: clarifications regarding struct-typeKaz Kylheku2019-03-131-0/+12
| | | | | * txr.1: Clarifying text added under find-struct-type and struct-type-p to better explain struct-type.
* oop: make struct symbol supertype of all structs.Kaz Kylheku2019-03-132-2/+14
| | | | | | | | * lib.c (subtypep): If the supertype is struct, then return t if the subtype is the name of a struct type. * txr.1: Update the type graph to show the struct root, adding a note about it.
* lazy conses: support state in car and cdr.Kaz Kylheku2019-03-134-6/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here we allow application code to take advantage of a trick already used internally. When a lazy cons cell is created, we can temporarily put state information into its car and cdr fields. When these fields are accessed normally, by the car and cdr function, the lazy cons' update function will be invoked, which will populate these fields. If we have a way for that function to retrieve the existing values of those fields, then the function can treat those fields as state information: it can retrieve the values into temporary local variables, overwrite the original values, and then propagate the state information into the car and cdr into the next lazy cons cell being added. Thus lazy list generation that needs two cells of state or less does not require the allocation of a context object. * eval.c (eval_init): make-lazy-cons becomes a three-argument function with two optional parameters. New functions lcons-car and lcons-cdr are registered. * lib.c (make_lazy_cons_pub): New function, wrapping make_lazy_cons_car_cdr with argument defaulting. (lcons_car, lcons_cdr): New functions. * lib.h (make_lazy_cons_pu, lcons_car, lcons_cdr): Declared. * txr.1: Updated doc of make-lazy-cons regarding new arguments. Documented lcons-car and lcons-cdr.
* lib: use accessor for lcons function.Kaz Kylheku2019-03-122-6/+7
| | | | | | | | * hash.c (hash_keys_lazy, hash_values_lazy, hash_pairs_lazy, hash_alist_lazy): Use us_lcons_fun instead of direct lcons->lc.fun access. * lib.c (simple_lazy_stream_func, lazy_stream_func): Likewise.