summaryrefslogtreecommitdiffstats
path: root/share/txr/stdlib
Commit message (Collapse)AuthorAgeFilesLines
* Version 132.txr-132Kaz Kylheku2016-01-151-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 131.txr-131Kaz Kylheku2016-01-121-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Version 130.txr-130Kaz Kylheku2016-01-051-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* defstruct: order function slots before other static slots.Kaz Kylheku2016-01-031-15/+17
| | | | | | | | | | | | | | | | | This allows the initializer expressions for static slots to instantiate objects, and those instances can rely on methods being set up. * share/txr/stdlib/struct.tl (sys:prune-nil-inits): Recognize :function keyword as denoting a static slot. (defstruct): Represent methods and functions as (:function ...) items rather than (:static ...) so they can be distinguished. Function slots appear before other static slots in the static slot list, and their initializing code is placed into the the static-initfun lambda of the sys:make-struct-type call in this order. * txr.1: Documented.
* Better bad slot syntax diagnostic in defstruct.Kaz Kylheku2016-01-031-1/+4
| | | | | | * share/txr/stdlib/struct.tl (defstruct): Issue different error message for a slot specifier which isn't a symbol, and wasn't recognized as a special syntax.
* Copyright year bump.Kaz Kylheku2015-12-3112-12/+12
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, 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, 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/cadr.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/struct.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, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* Version 129.txr-129Kaz Kylheku2015-12-291-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Adding with-slots macro.Kaz Kylheku2015-12-271-0/+9
| | | | | | | | | * lisplib.c (place_set_entries): Add with-slots to autoload name list. * share/txr/stdlib/struct.tl (with-slots): New macro. * txr.1: Documented.
* Version 128.txr-128Kaz Kylheku2015-12-191-1/+1
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. Bumped copyright year in configure. (Could be last chance this year). * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New condlet macro; small change to iflet/whenlet.Kaz Kylheku2015-12-181-5/+12
| | | | | | | | | | | | | | | | | | | | | | | * eval.c (me_iflet_whenlet): Allow the test form to be an atomic expression instead of bindings. This allows iflet to be used as the sole target construct of condlet, while allowing condlet to have a fallback clause with t. It also means that an empty list of bindings is allowed (since it is the atom nil). * lisplib.c (ifa_set_entries): Add "condlet" to the autoload names for the ifa module. That's where we are adding condlet. * share/txr/stdlib/ifa.tl (sys:if-to-cond): New macro expander helper function, generalizing the writing cond-like macros based on if-like operators. (conda): Rewritten using sys:if-to-cond. (condlet): New macro. * txr.1: Documented change in iflet/whenlet. Documented condlet.
* Set macro ancestry info in place expansions.Kaz Kylheku2015-12-171-4/+14
| | | | | | | | | | | | | | | * eval.c (set_origin): New static function. (eval_init): Register set_origin as sys:set-macro-ancestor. * share/txr/stdlib/place.tl (sys:pl-expand): Set macro ancestry when expanding a place macro. (sys:cp-origin): New function. (call-update-expander, call-clobber-expander, call-delete-expander): Use sys:cp-origin to walk through expanded code and attach the place form as the macro ancestor of all the getter, setter or deleter calls, effectively to say that those calls are expansions of the place, which is approximately the case.
* Useful feature: object post-initialization.Kaz Kylheku2015-12-161-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Structs can now have code which executes after an object is initialized, which is useful for doing work like registering objects in global lists and whatever, when those actions need access to the initialized slots of the object. * share/txr/stdlib/struct.tl (defstruct): Handle :posinit syntax, by generating lambda as eighth argument of sys:make-struct call. * struct.c (struct struct_type): New member, postinitfun. (struct_init): Adjust registrations of make_struct_type to account for new parameter. The user visible make-struct-type is registered as having one optional argument, for backward compat. (make_struct_type): New argument, postinitfun. Store this in the structure. For backward compatibility, the argument is defaulted. (struct_type_mark): Mark the new postinitfun member. (call_postinitfun_chain): New static function. (make_struct, lazy_struct_init): Call call_postinitfun_chain after slots are initialized, and after the boa function is called. * struct.h (make_struct_type): Declaration updated. * lib.c (time_init): Pass eighth argument to make_struct type. * sysif.c (sysif_init): Likewise. * unwind.c (uw_late_init): Likewise. * tests/012/struct.tl: Update defstruct expansion test case. * txr.1: Document new argument of make-struct-type, and clarify ordering of initfun with regard to other actions. Likewise, document :postinit, and clarify ordering of :init actions with regard to other actions.
* symbol-function semantics change; new symbol-macro.Kaz Kylheku2015-12-101-0/+16
| | | | | | | | | | | | | | | | | | | | | | | * eval.c (symbol_function): Only retrieve function binding, and not macro or operator bindings, unless compatibility <= 127 is in effect. (symbol_macro): New function. (fboundp): Only test for existence of function, not macro or operator, unless <= 127 compatibility is in effect. (fmakunbound): Do not remove macro binding, unless compatibility <= 127 is in effect. (eval_init): Register sys:top-mb variable for use in place.tl library module. Register symbol-macro intrinsic function. * share/txr/stdlib/place.tl (sys:get-mb): New function (symbol-macro): New syntactic place. * txr.1: Updated incorrect documentation about environments from the perspective that macros and functions coexist. Documented symbol-macro. Updated symbol-function, fboundp and fmakunbound documentation. Added missing documentation for mmakunbound. Reference to fboundp under define-place-macro revised to mboundp. Added compatibility notes.
* Version 127.txr-127Kaz Kylheku2015-12-091-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* defmeth returns compound method name.Kaz Kylheku2015-12-091-1/+1
| | | | | * share/txr/stdlib/struct.tl (sys:defmeth): Return compound method name as return value: (meth <type> <name>).
* Bugfix: ifa must allow dwim expressions.Kaz Kylheku2015-12-091-3/+6
| | | | | | | | * share/txr/stdlib/ifa.tl (ifa): Accept dwim expressions as the condition. Moreover, treat [f x] as a one-argument call, even though it is the two-argument form (dwim f x). * txr.1: Documented.
* Correct return value of defmeth.Kaz Kylheku2015-11-301-3/+4
| | | | | * share/txr/stdlib/struct.tl (defmeth): Return the symbol being defined.
* Version 126.txr-126Kaz Kylheku2015-11-291-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Bugfix: sethash doesn't return stored value.Kaz Kylheku2015-11-251-7/+11
| | | | | | | | | | | | | | | | 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-251-0/+19
| | | | | | | | | | | * 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.
* Version 125.txr-125Kaz Kylheku2015-11-201-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Introducing lazy structs.Kaz Kylheku2015-11-201-0/+12
| | | | | | | | | | | | | | | | | | | | | | | * 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.
* New uslot function and usl macro.Kaz Kylheku2015-11-201-0/+3
| | | | | | | | | | | | | | * 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.
* Version 124.txr-124Kaz Kylheku2015-11-141-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Version 123.txr-123Kaz Kylheku2015-11-061-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Version 122.txr-122Kaz Kylheku2015-11-051-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* yield-from can omit form; access initial value.Kaz Kylheku2015-11-041-13/+25
| | | | | | | | | | | | | * share/txr/stdlib/yield.tl (sys:rcv-item): New struct type. (sys:obtain-impl): Handle rcv-item, produced by a no-argument yield-from, which requests an immediate resumption with the previously given resume value. The reply value is renamed the resume value. (yield-from, yield): Form argument is optional. * txr.1: Rewrote obtain and yield documentation with lesser focus on implementation and greater focus on abstract semantics.
* Moving sys:capture-cont to call/cc style API.Kaz Kylheku2015-11-021-18/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Define suspend operator.Kaz Kylheku2015-10-301-0/+8
| | | | | | | | | | * 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.
* Version 121.txr-121Kaz Kylheku2015-10-291-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Provide a way to free the continuation stacks.Kaz Kylheku2015-10-291-2/+5
| | | | | | | | | | | | | | | | | | * 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-291-7/+10
| | | | | | | | | | * 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.
* Implementing sys:abscond-from operator.Kaz Kylheku2015-10-281-2/+3
| | | | | | | | | | | | | | | | | | | | | * 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.
* Add obtain/yield macros interface to continuations.Kaz Kylheku2015-10-281-0/+59
| | | | | | | | | | | * 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.
* Improvement in place macros.Kaz Kylheku2015-10-281-10/+15
| | | | | | | | | | | 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.
* Bugfix: incompletely implemented zap macro.Kaz Kylheku2015-10-251-2/+2
| | | | * share/txr/stdlib/place.tl (zap): Missing second argument.
* Version 120.txr-120Kaz Kylheku2015-10-181-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Adding defmeth macro and static-slot-ensure.Kaz Kylheku2015-10-161-0/+7
| | | | | | | | | | | | | | | | | * 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.
* Adding typecase macro.Kaz Kylheku2015-10-141-0/+38
| | | | | | | | | | * lisplib.c (type_set_entries, type_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/type.tl: New file, providing typecase * txr.1: Documented typecase.
* New way of handling exceptions without unwinding.Kaz Kylheku2015-10-141-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (handler_bind_s): New symbol variable. (op_handler_bind): New static function. (do_expand): Traverse handler-bind forms. (eval_init): Initialize handler_bind_s variable and register handler-bind operator. * lisplib.c (except_set_entries, except_instantiate): New functions. (lisplib_init): Register new functions in dl_table. * parser.c (intr_s): New symbol variable. (repl_intr): Throw exception of type intr, rather than error. This way we can interrupt accidental exception handling loops involving exceptions derived from error. (parse_init): Initialize intr_s. * share/txr/stdlib/except.tl: New file, defines handle macro. * unwind.c (uw_push_handler): New function. (invoke_handler): New static function. (uw_throw): Search loop looks for and processes handlers in addition to catches. * unwind.h (uw_frtype_t): New enum member, UW_HANDLE. (struct uw_catch): Move member visible so it is in the same position as in struct uw_handler. (struct uw_handler): New struct type. (union uw_frame): New member ha of type struct uw_handler. (uw_push_handler): Function declared. * txr.1: Added introductory paragraphs to Exception Handling section. Documented handler-bind and handle. Some minor errors corrected.
* Hash table iterators exposed, with new macro.Kaz Kylheku2015-10-111-0/+41
| | | | | | | | | | | * eval.c (eval_init): Register hash-begin and hash-next intrinsics. * lisplib.c (hash_set_entries, hash_instantiate): New static functions. (lisplib_init): Register new tables in dl_table. * share/txr/stdlib/hash.tl: New file. * txr.1: Document with-hash-iter macro.
* Struct finalizers should be registered first.Kaz Kylheku2015-10-101-13/+13
| | | | | | | | | | | * share/txr/stdlib/struct.tl (defstruct): Rearrange the generated instance initialization function so that if a :fini block was specified, it is performed first. Thus if the remaining initialization code is abandoned, it is possible to intercept that and invoke the finalizer, which can clean up any mess left behind. * txr.1: Document changed order.
* defstruct bugfix: nonexistent function called.Kaz Kylheku2015-10-101-6/+6
| | | | | * share/txr/stdlib/struct.tl (defstruct): The nonexistent uw-throwf function was called instead of throw.
* Version 119.txr-119Kaz Kylheku2015-10-101-1/+1
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* New macro: with-objects.Kaz Kylheku2015-10-101-0/+8
| | | | | | | | | | | * lisplib.c (with_resources_set_entries): "with-objects" added to name table. * share/txr/stdlib/with-resources.tl (with-objects): New macro. * txr.1: Documented with-objects. Added note to :fini specifier of defstruct pointing to call-finalizers and with-objects.
* Various stream-related with- macros introduced.Kaz Kylheku2015-10-081-0/+48
| | | | | | | | | | * lisplib.c (with_stream_set_entries, with_stream_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/with-stream.tl: New file. * txr.1: Documented new macros.
* Optional arguments in boa construction.Kaz Kylheku2015-10-041-5/+20
| | | | | | | | | | | | * share/txr/stdlib/struct.tl (defstruct): Split boa arguments on colon and generate the lambda accordingly. The generated function detects which optional arguments are actually present and only performs the slot updates for those. * tests/012/struct.tl: Corrected boa test case. * txr.1: Documented.
* slot-p renamed to slotp, conforming with Lisp conventions.Kaz Kylheku2015-10-031-1/+1
| | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (sys:prune-nil-inits): Use of slot-p renamed. * struct.c (struct_init): Register slotp, and make registration of slot-p conditional on compatibility option. (slot_p): Function renamed to slotp. * struct.h (slot_p): Declaration renamed. * txr.1: References to slot-p fixed to slotp. Compat notes added.
* New umeth and umethod macro and function.Kaz Kylheku2015-10-031-0/+3
| | | | | | | | | | * share/txr/stdlib/struct.tl (umeth): New macro. * struct.c (struct_init): Registered umethod intrinsic. (umethod_fun): New static function. (umethod): New function. * txr.1: Documented.