summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Add amb test case for continuations.Kaz Kylheku2015-11-021-0/+20
| | | | | | * tests/012/cont.tl (amb-scope): New macro. (amb): New function. New test case using amb.
* Moving sys:capture-cont to call/cc style API.Kaz Kylheku2015-11-024-59/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * unwind.c (revive_cont): Don't wrap cons cell around passed arg; just pass it directly. We don't need that convention any more. * capture_cont: Take functional argument. Pass the captured continuation to the function. If the function returns, return whatever it returned. When resuming, return the continuation argument. (uw_capture_cont): Take functional second argument and pass to capture_cont. Context form becomes third argument. (uw_late_init): Update registration of sys:capture-cont to three arguments, two required. * unwind.h (uw_capture_cont): Declaration updated. * share/txr/stdlib/yield.tl (sys:yield-impl): Not needed any more; all this was doing was implementing a call/cc style interface around sys:capture-cont which can now be used directly. (yield-from): Use sys:capture-cont directly. (suspend): Simplified to the point of triviality with new sys:capture-cont. * txr.1: Documented.
* New range type, distinct from cons cell.Kaz Kylheku2015-11-0110-43/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register intrinsic functions rcons, rangep from and to. (eval_init): Register rangep intrinsic. * gc.c (mark_obj): Traverse RNG objects. (finalize): Handle RNG in switch. * hash.c (equal_hash, eql_hash): Hashing for for RNG objects. * lib.c (range_s, rcons_s): New symbol variables. (code2type): Handle RNG type. (eql, equal): Equality for ranges. (less_tab_init): Table extended to cover RNG. (less): Semantics defined for ranges. (rcons, rangep, from, to): New functions. (obj_init): range_s and rcons_s variables initialized. (obj_print_impl): Produce #R notation for ranges. (generic_funcall, dwim_set): Recognize range objects for indexing * lib.h (enum type): New enum member, RNG. MAXTYPE redefined to RNG value. (TYPE_SHIFT): Increased to 5 since there are now 16 type codes. (struct range): New struct type. (union obj): New member rn, of type struct range. (range_s, rcons_s, rcons, rangep, from, to): Declared. (range_bind): New macro. * parser.l (grammar): New rule for recognizing the #R sequence as HASH_R token. * parser.y (HASH_R): New terminal symbol. (range): New nonterminal symbol. (n_expr): Derives the new range symbol. The n_expr DOTDOT n_expr rule produces rcons expression rather than const. * match.c (format_field): Recognize rcons syntax in fields which is now what ranges translate to. Also recognize range object. * tests/013/maze.tl (neigh): Fix code which destructures range as a cons. That can't be done any more. * txr.1: Document ranges.
* Fix case in Compatibility section reference.Kaz Kylheku2015-10-311-1/+1
| | | | * txr.1: Compatibility -> COMPATIBILITY
* Define suspend operator.Kaz Kylheku2015-10-303-35/+104
| | | | | | | | | | * lisplib.c (yield_set_entries): Added "suspend" to end of name. * share/txr/stdlib/yield.tl (suspend): New macro. * txr.1: Documented suspend. Replaced subtly incorect shift/reset implementation example with suspend implementation.
* Support Power PC 64.Kaz Kylheku2015-10-302-0/+88
| | | | | | * jmp.S (jmp_save, jmp_restore): Add PPC64 versions. * signal.h (struct jmp): Add PPC64 version.
* Version 121.txr-121Kaz Kylheku2015-10-296-534/+568
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Formatting issue under qref.Kaz Kylheku2015-10-291-1/+1
| | | | * txr.1: Improperly terminated .cblk.
* Provide a way to free the continuation stacks.Kaz Kylheku2015-10-293-42/+66
| | | | | | | | | | | | | | | | | | * share/txr/stdlib/yield.tl (sys:obtain-impl): Pass sys:cont-free symbol to each abandoned continuation to release its stack buffer. (obtain): Handle the sys:cont-free symbol in the lambda, so the initial lambda can be treated uniformly with continuation functions. * txr.1: Documented sys:obtain-impl. * unwind.c (sys_cont_free_s): New symbol variable. (cont_mark): Check for null stack pointer and avoid marking. (revive_cont): If arg is sys:cont-free, then free the continuation and return nil. If the continuation has a null stack buffer, throw an error. (uw_late_init): Initialize sys_cont_free_s.
* Finalize obtain continuator function.Kaz Kylheku2015-10-292-7/+20
| | | | | | | | | | * share/txr/stdlib/yield.tl (sys:obtain-impl): Add a finalizer to the returned closure which will feed sys:cont-poison object to the most recently captured continuation. Thus abandoned obtain blocks which have become garbage shall have their unwinding performed. * txr.1: Documented the finalization behavior.
* Unwinding continuations via "poison" value.Kaz Kylheku2015-10-292-2/+11
| | | | | | | | | | | | * unwind.c (sys_cont_poison_s): New symbol variable. (revive_cont): If the argument is the poison symbol, then unwind through the continuation all the way back to revive_cont's own block, instead of to the continuation's very top block. Thus the continuation is not restarted but completely unwound. (uw_late_init): Initialize sys_cont_poison_s. * txr.1: Documented sys:cont-poison.
* Implementing sys:abscond-from operator.Kaz Kylheku2015-10-285-5/+121
| | | | | | | | | | | | | | | | | | | | | * eval.c (sys_abscond_from_s): New symbol variable. (op_abscond_from): New static function. (do_expand): Handle abscond-from like return-from. (eval_init): Initialize sys_abscond_from_s and register sys:abscond-from operator. * share/txr/stdlib/yield.tl (yield-from): Use sys:abscond-from instead of return-from, to avoid tearing down the continuation's resources that it may need when restarted. * txr.1: Documented sys:abscond-from and added a mention to the Delimited Continuations introduction. * unwind.c (uw_abscond_to_exit_point): New static function. (uw_block_abscond): New function. * unwind.h (uw_block_abscond): Declared.
* Doc maintenance under flet and labels.Kaz Kylheku2015-10-281-1/+15
| | | | | | * txr.1: Some wording changes and dialect note that flet and labels do not genearate implict named blocks in the function bodies.
* Bugfix: harden hash-next, since it is exposed.Kaz Kylheku2015-10-281-1/+4
| | | | | | | | | | | The C code doesn't call hash_next once it returns nil, so it doesn't matter that doing so will dereference a null pointer. But hash_next is now exposed as the Lisp function hash-next. * hash.c (hash_next): If the hash table in the iterator is nil, then return nil, avoiding the dereference of a null pointer.
* Fix with-hash-table-iter typo.Kaz Kylheku2015-10-282-2/+2
| | | | | | | * lisplib.c (hash_set_entries): Change with-hash-table-iter to with-hash-iter. * txr.1: Likewise.
* Add some tests for continuations.Kaz Kylheku2015-10-282-0/+19
| | | | | | * tests/012/cont.tl: New file. * tests/012/cont.expected: New file.
* Add obtain/yield macros interface to continuations.Kaz Kylheku2015-10-283-0/+328
| | | | | | | | | | | * lisplib.c (yield_set_entries, yield_instantiate): New static functions. (dlt_register): Registered new functions. * share/txr/stdlib/yield.tl: New file. * txr.1: Documented obtain, yield-from, obtain-block and yield.
* Context form error reporting in sys:capture-cont.Kaz Kylheku2015-10-283-18/+24
| | | | | | | | | | | | | | * unwind.c (sys_capture_cont_s): New variable. (uw_capture_cont): Second argument is now a context form rather than a symbol; eval_error is used for error reporting. The form's operator symbol si used in the error message, or else sys:capture-cont if the context argument is null or missing. (uw_late_init): Initialize sys_capture_cont_s. * unwind.h (uw_capture_cont): Declaration updated. * txr.1: Documented.
* Expose eval_error out of eval module.Kaz Kylheku2015-10-282-1/+2
| | | | | | * eval.c (eval_error): Static function made external. * eval.h (eval_error): Declared.
* Move noreturn macro.Kaz Kylheku2015-10-282-6/+6
| | | | | | * lib.h (noreturn): Defined here. * unwind.h (noreturn): Removed from here.
* New special macro parameter list parameter :form.Kaz Kylheku2015-10-282-12/+30
| | | | | | | | * eval.c (form_k): New keyword symbol variable. (bind_macro_params): Implement form_k. (eval_init): Initialize form_k. * txr.1: Documented :form parameter.
* Improvement in place macros.Kaz Kylheku2015-10-282-13/+40
| | | | | | | | | | | Expansion of places now gives priority to place macros. Moreover, it iterates over place macro and ordinary macro expansion. * share/txr/stdlib/place.tl (sys:trigger-load): Removed. (sys:pl-expand): Rewritten. * txr.1: Documented.
* Remove no-longer-needed bulk bit operations.Kaz Kylheku2015-10-271-17/+3
| | | | | | | * signal.c (mem_set_bits, mem_clr_bits): Static functions removed. (sig_mask): Operate on set member of small_sigset_t directly rather than as an array of bytes.
* Fix C++ clash in slots implementation.Kaz Kylheku2015-10-271-2/+2
| | | | | * struct.c (make_struct_type): Don't use nullptr identifier as variable name.
* Reduce size of saved/restored signal masks.Kaz Kylheku2015-10-272-23/+31
| | | | | | | | | | | | | | | | | | | | | | | | | On glibc, sigset_t has a ridiculous size: one kilobyte! The kernel doesn't access most of it in the sigprocmask call. Yet it blows up the size of our dynamic frames quite a lot. In this commit, we define a small_sigset_t type and use that instead. We convert to the bloated one when calling the library. * signal.c (sig_blocked_cache): Type changes to small_sigset_t. (sig_reload_cache): Retrieve signal mask with sigprocmask into a local variable, then copy a small portion from that to sig_blocked_cache. (small_sigfillset): New static function. (set_sig_handler): Local variables of sigset_t changed to small_sigset_t. (sig_mask): Arguments are pointers to small_sigset_t. Conversion to sigset_t done around the call to sigprocmask. * signal.h (copy_sigset): Inline funtion removed. (small_sigset_t): New struct type. (extended_jmp_buf): Member blocked changed to small_sigset_t. (extended_setjmp): Cast expression updated with small_sigset_t *. (extended_longjmp): Use assignment instead of copy_sigset. (sig_blocked_cache, sig_mask): Declarations updated.
* Fix *listener-hist-len* in ~/.txr_profile not working.Kaz Kylheku2015-10-271-3/+5
| | | | | | | | | | On startup, the history is trimmed to 100 lines regardless of the variable's value in the profile file. * parser.c (repl): Load the rc file first, then load the history file. Furthermore, call lino_hist_set_max_len between these operations with the latest value pulled from the *listener-hist-len* variable.
* Fix size growth of nested continuation capture.Kaz Kylheku2015-10-271-1/+2
| | | | | | | | | | | | | The issue is that captures from within a restarted continuation of the same continuation, are using the restart prompt as the delimiter rather than re-using captured block of the same name. Thus each successive capture adds a new frame, causing the size to grow drastically. * unwind.c (uw_capture_cont): Allow the existing captured block to be the delimiter; don't delimit up to the revive_cont's prompt block of the same name.
* Capture portion of stack beyond prompting block.Kaz Kylheku2015-10-261-1/+3
| | | | | | | | | | Without this we don't properly capture some of the context in some built-in special operator functions like op_for when we capture up to their implicit blocks. * unwind.c (capture_cont): Capture an extra region of the stack above the delimiting block. 32 words seems like a reasonable fudge value.
* TXR gets delimited continuations.Kaz Kylheku2015-10-253-5/+345
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * unwind.c (sys_cont_s): New symbol variable. (uw_pop_block): New function, supporting uw_block_end macro. Special logic is needed for popping blocks now, because a block can be a captured stub at the top of a continuation, which must not be popped in the regular manner. (struct cont): New struct type. (cont_destroy, cont_mark): New static functions. (cont_ops): New static structure. (revive_cont, capture_cont): New static functions. (uw_capture_cont): New functions. (uw_init): Initialize sys_cont_s. Register sys:capture-cont intrinsic. * unwind.h (enum uw_frtype): New enum member UW_CAPTURED_BLOCK. When a block is captured as a stub copy of the prompt block of a delimited continuation, its type is changed from UW_BLOCK to this new type. This does two things: it makes the block invisible to block-related code that does nothing with continuations (code that looks for UW_BLOCK and ignores anything else). Secondly, there is some special handling related to UW_CAPTURED_BLOCK frames. (uw_pop_block, uw_capture_cont): Declared. (uw_block_begin): New local pointer uw_rslt introduced which helps communicate the result variable over to the uw_block_end macro (so we don't have to add a variable argument to the latter). (uw_block_end): Use uw_pop_block instead of uw_pop_frame. * txr.1: Documented delimited continuations.
* Bugfix: incompletely implemented zap macro.Kaz Kylheku2015-10-251-2/+2
| | | | * share/txr/stdlib/place.tl (zap): Missing second argument.
* Expose memory region marking function.Kaz Kylheku2015-10-252-0/+6
| | | | | | * gc.c (gc_mark_mem): New function. * gc.h (gc_mark_mem): Declared.
* Stop using C library setjmp/longjmp.Kaz Kylheku2015-10-2526-32/+270
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR is moving to custom assembly-language routines. This is mainly motivated by a very dubious thing done in the GNU C Library setjmp and longjmp in the name of security. Evidently, glibc's setjmp "mangles" certain pointer values which are stored into the jmp_buf buffer. It's been that way since 2005, evidently. This means that, firstly, all along, the use of setjmp in gc.c to get registers into a buffer so they can be scanned has not actually worked properly. More importantly, this pointer mangling in setjmp and longjmp is very hostile to a stack copying implementation of delimited continuations. The reason is that continuations contain jmp_buf buffers, which get relocated in the process of capturing and reviving a continuation. Any pointers in a jmp_buf which point into the captured stack segment have to be fixed up to point into the relocated location. Mangled pointers make this difficult, requiring hacks which are specific to glibc and the machine architecture. We might as well implement a clean, well-behaved setjmp and longjmp. * Makefile (jmp.o): New object file. (dbg/%.o, opt/%.o): New rules for .S prerequisites. * args.c, arith.c, cadr.c, combi.c, cadr.c, combi.c, debug.c, eval.c, filter.c, glob.c, hash.c, lib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Removed <setjmp.h> include. * gc.c: Switch to struct jmp and jmp_save, instead of jmp_buf and setjmp. * jmp.S: New source file. * signal.h (struct jmp): New struct type. (jmp_save, jmp_restore): New function declarations denoting assembly language routines in jmp.S. (extended_jmp_buf): Uses struct jmp instead of setjmp. (extended_setjmp): Use jmp_save instead of setjmp. (extended_longjmp): Use jmp_restore instead of longjmp.
* Reduce stack usage for args in a few places.Kaz Kylheku2015-10-242-5/+3
| | | | | | * eval.c (apply, do_eval): Use ARGS_MIN instead of ARGS_MAX. * unwind.c (uw_throw): Ditto, when invoking handler.
* Implementing truncate-stream.Kaz Kylheku2015-10-215-10/+104
| | | | | | | | | | | | | | | | | | | | | | | * configure: Test for ftruncate and chsize. * stream.c (unimpl_truncate): New static function. (fill_stream_ops): Default the truncate operation to unimpl_truncate. (null_ops): Initialize truncate to unimpl_truncate. (stdio_truncate): New static function. (stdio_ops, tail_ops): Initialize truncate to stdio_truncate. (pipe_ops, dir_ops, string_ops, byte_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops): Initialize truncate to null, so it gets defaulted by fill_stream_ops. (truncate_stream): New function. (stream_init): Register truncate-stream intrinsic. * stream.h (struct strm_ops): New member, truncate. (strm_ops_init): New truncate argument added to macro. (truncate_stream): Declared. *syslog.c (syslog_strm_ops): Initialize truncate to null. * txr.1: Documented.
* Correction in error message on unimplemented seek.Kaz Kylheku2015-10-211-1/+1
| | | | | * stream.c (unimpl_seek): Function should identify itself as seek-stream, not seek.
* Doc improvements in Structures.Kaz Kylheku2015-10-191-10/+16
| | | | | * txr.1: mention defmeth in Structures intro plus a number of wording changes and corrections.
* defmeth and with-objects formatting fix.Kaz Kylheku2015-10-191-1/+2
| | | | | * txr.1: Bad syntax formatting in defmeth. Missing .desc under with-objects.
* Version 120.txr-120Kaz Kylheku2015-10-186-374/+430
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Bugfix: unterminated format argument list in repl code.Kaz Kylheku2015-10-181-1/+1
| | | | | * parser.c (repl): Missing nao terminator in format call which computes expression name.
* Support binary specifier in format.Kaz Kylheku2015-10-172-5/+31
| | | | | | | | * stream.c (formatv): New 'b' case along side 'o', handling binary in straightforward way for bignums, and with binary formatting loop code for fixnums. * txr.1: Documented b.
* Use chk_manage_vec for static slots arrays.Kaz Kylheku2015-10-171-4/+7
| | | | | | | | * struct.c (make_struct_type): Use chk_manage_vec for initial allocation of static slot array. (static_slot_ensure): Use chk_manage_vec to grow the array when adding a slot. The function will automatically double the array in power of two step sizes.
* New function chk_manage_vec.Kaz Kylheku2015-10-172-0/+51
| | | | | | | | | | | | This function manages a dynamic array using only the filled size as input, while minimizing reallocations. The allocated size is implicitly always the next power of two at or above the filled size. * lib.c (next_pow_two): New static function. (chk_manage_vec): New function. * lib.h (chk_manage_vec): Declared.
* Fix overflow check using wrong variable.Kaz Kylheku2015-10-171-1/+1
| | | | | * lib.c (chk_grow_vec): It is newelems which must be compared against the no_oflow value, not bytes.
* New test case for handle and frame introspection.Kaz Kylheku2015-10-172-0/+19
| | | | | | * tests/012/except.tl: New file. * tests/012/except.expected: New file.
* Streamline handling of struct type arguments.Kaz Kylheku2015-10-172-98/+86
| | | | | | | | | | * struct.c (stype_handle): New static function. (make_struct_type, super, make_struct, static_slot, static_slot_set, static_slot_ensure, slotp, static_slot_p): Use stype_handle, * txr.1: Documented that static-slot and static-slot-set take type as a symbol.
* Fix formatting under caar, cadr, ...Kaz Kylheku2015-10-161-0/+1
| | | | * txr.1: .cblk with no closing .cble.
* Adding defmeth macro and static-slot-ensure.Kaz Kylheku2015-10-164-0/+135
| | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (defmeth): New macro. * struct.c (struct struct_type): New member, dvtypes. (struct_init): Register static-slot-ensure intrinsic. (make_struct_type): Initialize dvtypes of newly instantiated struct_type struct. If a super is specified, add new type to the super's dvtypes. (struct_type_mark): Mark st->dvtypes. (static_slot_ensure): New function. * struct.h (static_slot_ensure): Declared. * txr.1: Documented defmeth and static-slot-ensure.
* Remove use of the system function.Kaz Kylheku2015-10-162-19/+35
| | | | | | | | | | System depends on environment variables, and also causes SIGINT and SIGQUIT to be ignored. * stream.c (sh): Function rewritten in terms of sh, in two platform variants. * txr.1: Documented that sh doesn't use system as of TXR 120.
* Most uses of auto_str should be static_str.Kaz Kylheku2015-10-161-3/+3
| | | | | | | | | These functions do exactly same thing, but communicate something different to the reader of the code. An auto_str is on the stack, and so must not be passed somewhere where it will be retained. * txr.c (help, compat, txr_main): Use static_str on version.
* Renaming some functions for consistency.Kaz Kylheku2015-10-168-42/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * combi.c (perm_list, perm_str, rperm_list, reperm_gen_fun, rperm_vec, comb_vec, rcomb_list, rcomb_vec, rcomb_str): Follow rename of list_vector to list_vec. * eval.c (vector_list_s): Global variable renamed to vec_list_s. (expand_qquote): Follow vector_list_s to vec_list_s. (eval_init): Follow renames of all identifiers. Functions num-chr, chr-num, vector-list and list-vector are registered under new names, while remaining registered under old names. * eval.h (vector_list_s): Declaration renamed. * filter.c (url_encode): Follow chr_num to chr_int rename. * lib.c (make_like, interpose, shuffle): Follow vector_list to vec_list rename. (tolist, replace, replace_list): Follow list_vector to list_vec rename. (num_chr): Renamed to int_chr. (chr_num): Renamed to chr_int. (vector_list): Renamed to vec_list. (list_vector): Renamed to list_vec. * lib.h (num_chr, chr_num, list_vector, vector_list): * Declarations renamed. * parser.y (vector): Follow vector_list to vec_list rename. * txr.1: Updated documentation for num-chr, chr-num, list-vector and vector-list with new names, and notes about the old names being supported, but obsolescent.