summaryrefslogtreecommitdiffstats
path: root/lisplib.c
Commit message (Collapse)AuthorAgeFilesLines
* Copyright year bump 2018.Kaz Kylheku2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.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, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, win/cleansvg.txr: Extended Copyright line to 2018.
* bugfix: intern public symbols in autoload files.Kaz Kylheku2018-02-071-0/+29
| | | | | | | | | | | | | | | | | | | | | | | This commit addresses a bug of the following type: (defpackage p (:fallback usr)) (in-package p) (let ((lb (new list-builder))) lb.(add 1)) ;; problem: this add is p:add the add symbol is not on the auto-load list; it occurs as a slot of the list-builder class, but is not interned when TXR starts. Thus the (:fallback usr) doesn't pick it up. Expected behavior is that add is usr:add. * lisplib.c (intern_only): New static function. (sock_set_entries, build_set_entries, getopts_set_entries, stream_wrap_set_entries): Define additional lists of supplemenary symbols which are passed to intern_only just to be interned in the usr package without autoload registratiions. These symbols are all slots documented for public use in various structures defined by the respective modules managed by these autoload functions.
* Fix broken autoload of socket functions.Kaz Kylheku2018-01-251-0/+3
| | | | | | | * lisplib.c (sock_set_entries): Add missing sock-bind, sock-connect, sock-listen, sock-accept, sock-shutdown, open-socket, open-socket-pair, sock-send-timeout and sock-recv-timeout.
* New feature: structure delegate streams.Kaz Kylheku2017-12-081-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new kind of stream object which redirects its operations to the methods of a structure. * Makefile (OBJS): New object file, strudel.o. * lib.c (init): Call new strudel_init function. * lisplib.c (stream_wrap_set_entries, stream_wrap_instantiate): New static functions. (lisplib_init): Arrange for autloading of new stream-wrap.tl. * share/txr/stdlib/stream-wrap.tl: New file. * stream.c (put_string_s, put_char_s, put_byte_s, get_line_s, get_char_s, get_byte_s, unget_char_s, unget_byte_s, put_buf_s, fill_buf_s, flush_s, seek_s, truncate_s, get_prop_s, set_prop_s, get_error_s, get_error_str_s, clear_error_s, get_fd_s): New symbol variables. (stream_init): New symbol variables initialized. Numerous functions registered via these variables now rather than intern(...) expressions. * stream.h (put_string_s, put_char_s, put_byte_s, get_line_s, get_char_s, get_byte_s, unget_char_s, unget_byte_s, put_buf_s, fill_buf_s, flush_s, seek_s, truncate_s, get_prop_s, set_prop_s, get_error_s, get_error_str_s, clear_error_s, get_fd_s): Declared. * strudel.c, strudel.h: New files.
* New convenience I/O functions for buffers.Kaz Kylheku2017-10-271-0/+2
| | | | | | | | | | | | | * lisplib.c (getput_set_entries): New autoload entries for file-get-buf, file-put-buf, file-append-buf, command-get-buf and command-put-buf. * share/txr/stdlib/getput.tl (sys:get-buf-common): New function. (file-get-buf, file-put-buf, file-append-buf, command-get-buf, command-put-buf): New functions. * txr.1: Documented.
* New variant of op: lop.Kaz Kylheku2017-10-191-1/+1
| | | | | | | | | | * lisplib.c (op_set_entries): Add lop to auto-load list. * share/txr/stdlib/op.tl (sys:op-expand): Recognize lop and implement its transformation. (lop) New macro. * txr.1: Documented.
* Rewriting op/do macros in Lisp.Kaz Kylheku2017-08-291-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new implementation treats the @1, @2 ... @rest op arguments as local macros, leveraging the power of the macro expander to perform the substitution which renames these to gensyms. As a result, the implementation is correct. The old implementation blindly walks the tree structure doing the substitution, so that @1 is substituted even though it is in a quoted literal: [(op list '(@1)) 42] -> ((#:arg-01-0166)) under the new implementation, '(@1) is left alone: [(op list '(@1)) 42] -> ((@1) 42) * eval.c (expand_quasi): Because the new op macro doesn't rudely reach into quasi forms to substitute sys:var elements, relying on macro expansion, we must now macro-expand sys:var elements. The sys:var macro created by op is smart enough to skip the compound ones that have modifiers; they are handled via the inner expansion of the symbol. That is to say, `@@1` contains the structure (sys:var (sys:var 1)). The sys:var macro ignores the outer sys:var. But existing behavior in expand_quasi expands the inner (sys:var 1), so the substitution takes place. (eval_init): Do not register the hacky old op and do macros, except in compatibility mode with 184 or older. * lisplib.c (op_set_entries, op_instantiate): New functions. (dlt_register): Register auto-loads for op and do macros via new functions, except when in compatibility mode with 184 or older, in which case we want the old build-in hacky op to be used. * share/txr/stdlib/op.tl: New file. * txr.1: Fixed or removed no-longer-true text which hints at special hacks implemented in the op expander. Added compatibility notes for all new compat-switched op behaviors.
* buf: new buffer stream.Kaz Kylheku2017-08-141-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * buf.c (struct buf_strm): New struct type. (buf_strm_mark, int buf_strm_put_byte_callback, buf_strm_put_string, buf_strm_put_char, buf_strm_put_byte, buf_strm_get_byte_callback, buf_strm_get_char, buf_strm_get_byte, buf_strm_unget_char, buf_strm_unget_byte, buf_strm_seek, buf_strm_truncate, buf_strm_get_prop, buf_strm_set_prop, buf_strm_get_error, buf_strm_get_error_str): New static functions. (buf_strm_ops): New static struct. (buf_strm): New static function. (make_buf_stream, get_buf_from_stream): New functions. (buf_init): Register new intrinsic functiions make-buf-stream and get-buf-from-stream. Call fill_stream_ops on new buf_strm_ops to fill default operations in place of function pointers that have been left null. * buf.h (make_buf_stream, get_buf_from_stream): Declared. * lisplib.c (with_stream_set_entries): Add with-out-buf-stream and with-in-buf-stream to auto-load symbols for with-stream.tl module. * share/txr/stdlib/with-stream.tl (with-out-buf-stream, with-in-buf-stream): New macros. * txr.1: New section about buffer streams.
* New macros doloop and doloop*.Kaz Kylheku2017-07-301-0/+18
| | | | | | | | | | * lisplib.c (doloop_set_entries, doloop_instantiate): New functions. (lisplib_init): Register autoload for doloop macros. * share/txr/stdlib/doloop.tl: New file. * txr.1: Documented.
* ffi: new make-zstruct function and znew macro.Kaz Kylheku2017-07-021-0/+1
| | | | | | | | | | | | | * ffi.c (make_zstruct): New function. (ffi_init): Register make-zstruct instrinsic. * ffi.h (make_zstruct): Declared. * lisplib.c (ffi_set_entries): Add znew to autload list. * share/txr/stdlib/ffi.tl (znew): New macro. * txr.1: Documented make-zstruct and znew.
* ffi: new macro, deffi-sym.Kaz Kylheku2017-06-261-3/+3
| | | | | | | | * lisplib.c (ffi_set_entries): Add deffi-sym to autload list. * share/txr/stdlib/ffi.tl (deffi-sym): New macro. * txr.1: Documented.
* ffi: turn carray-sub into accessor.Kaz Kylheku2017-06-131-1/+1
| | | | | | | | | | | | | | | | * lisplib.c (ffi_set_entries): Register carray-sub for autoload. * share/txr/stdlib/ffi.tl (carray-sub): New place macro, aliases to sub. This is not 100% correct since that means it will admit non-carray objects, but the alternative is to clone the entire sub expander with a few changes, or else factor out sub expansion into a shared routine. Bleh ... * txr.1: Documented. We don't cover up the ruse we perpetrated, and reveal that it's just a place macro targetting sub.
* bugfix: autoload syntactic places.Kaz Kylheku2017-06-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | TXR Lisp doesn't autoload the definition of places. For instance if a (set (foo x) y) appears out of the blue and foo is keyed for autoload, it doesn't happen. The right place to fix this is to do the autload check in the place macro expander, since every place form is tried as a macro. We need to expose the lisplib_try_load function as a Lisp intrinsic. * lisplib.c (lisplib_init): Register sys:try-load intrinsic, mapped to lisplib_try_load. * share/txr/stdlib/place.tl (sys:get-place-macro): New function. (sys:pl-expand): Use sys:get-place-macro instead of direct lookup in *place-macro* hash. The new function tries to autoload the symbol if it finds no place macro for it.
* ffi: functions and macros for basic type properties.Kaz Kylheku2017-06-021-2/+3
| | | | | | | | | | | | | | | | | | * ffi.c (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): New functions. (ffi_init): Registered intrinsics ffi-alignof, ffi-offsetof, ffi-arraysize, ffi-elemsize, ffi-elemtype. * ffi.h (ffi_alignof, ffi_offsetof, ffi_arraysize, ffi_elemsize, ffi_elemtype): Declared. * lisplib.c (ffi_set_entries): New autoload entries alignof, offsetof, arraysize, elemsize, elemtype. * share/txr/stdlib/ffi.tl (alignof, offsetof, arraysize, elemsize, elemtype): New macros. * txr.1: Documented new functions and macros.
* ffi: new macro, deffi-var.Kaz Kylheku2017-05-201-1/+2
| | | | | | | | * lisplib.c (ffi_set_entries): Autload entry for "deffi-var". * share/txr/stdlib/ffi.tl (deffi-var): New macro. * txr.1: Documented.
* ffi: turn carray-ref into accessor.Kaz Kylheku2017-05-201-1/+1
| | | | | | | | | | * lisplib.c (ffi_set_entries): Add carray-ref to list of autoload names. * share/txr/stdlib/ffi.tl (carray-ref, carray-refset): Registered function pair as a simple accessor. * txr.1: Updated carray-ref doc.
* ffi: macro named ffi for type compiling shorthand.Kaz Kylheku2017-05-171-1/+1
| | | | | | | | | * lisplib.c (ffi_set_entries): Add "ffi" to autoload name list. * share/txr/stdlib/ffi.tl (ffi): New macro. * txr.1: Documented.
* ffi: typedef macro instead of deffi-type.Kaz Kylheku2017-05-171-1/+1
| | | | | | | | | | * share/txr/stdlib/ffi.tl (typedef): New macro. * lisplib.c (ffi_set_entries): Add typedef to autoload name list. * txr.1: Doc update. Remove mentions of deffi-type, though it continues to work.
* ffi: add macro language.Kaz Kylheku2017-05-061-0/+19
| | | | | | | | * lisplib.c (ffi_set_entries, ffi_instantiate): New static functions. (lisplib_init): Register auto-loading of ffi.tl. * share/txr/stdlib/ffi.tl: New file.
* Use original *packages-alist* value for auto-load.Kaz Kylheku2017-03-181-0/+1
| | | | | | | | | | | * lisplib.c (lisplib_try_load): Around the load, don't just bind *package* to the user package, but also *package-alist* to the original initialization-time list of packages. This allows auto-loading to work in sandboxed code. This has security implications: if sandboxed code can somehow trigger an error situation in an auto-load which then calls back into a handler in the sandboxed code, it then has access to the full usr and sys packages.
* trace: implement redefinition checks.Kaz Kylheku2017-03-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The tracing module should warn when traced functions or methods are being redefined, and stop tracing the original methods. * eval.c (trace_check): New function. Calls sys:trace-redefined-check if the trace module has been loaded, otherwise does nothing. (op_defun, op_defmacro): Call trace_check to have a warning issued for a redefined traced function or macro. * eval.h (trace_check): Declared. * lisplib.c (trace_loaded): New global variable. (trace_instantiate): Flip trace_loaded to t. * lisplib.h (trace_loaded): Declared. * share/txr/stdlib/trace.tl (sys:trace-redefine-check): New function. Checks two situations: traced function or method is redefined (neither old nor new is traced any longer), and traced method is overridden (base method continues to be traced, override is not traced). * struct.c (static_slot_ensure): Do a trace check here, taking care of defmeth.
* uref: the a.b.c syntax extended to .a.b.cKaz Kylheku2017-03-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now it is possible to use a leading dot on the referencing dot syntax. This is the is the "unbound reference dot". It expands to the uref macro, which denotes an unbound-reference: it produces a function which takes an object as the argument, and curries the reference implied by the remaining arguments. * eval.c (uref_s): New global symbol variable. (eval_init): Intern uref symbol and init uref_s. * eval.h (uref_s): Declared. * lib.c (simple_qref_args_p): A qref expression is now also not simple if it contains an embedded uref, meaning that it cannot be rendered into the dot notation without ambiguity. (obj_print_impl): Support printing (uref a b c) as .a.b.c. * lisplib.c (struct_set_entries): Add uref to the list of autoload triggers for struct.tl. * parser.l (DOTDOT): Consume any leading whitespace as part of recognizing the DOTDOT token. Otherwise the new rule for UREFDOT, which matches (mandatory) leading space will take precedence, causing " .." to be scanned wrong. (UREFDOT): Rule for new kind of dot token, which is preceded by mandatory whitespace, and isn't consing dot (which has mandatory trailing whitespace too, matched by an earlier rule). * parser.y (UREFDOT): New token type. (i_dot_expr, n_dot_expr): New grammar rules. (list): Handle a leading dot on the first element of a list as a special case. Things are done this way because trying to work a UREFDOT into the grammar otherwise causes intractable conflicts. (i_expr): The ^, ' and , punctuators are now followed by an i_dot_expr, so that the expression can be an unbound dot. (n_expr): Same change as in i_expr, but using n_dot_expr. Plus new UREFDOT n_expr production. * share/txr/stdlib/struct.tl (uref): New macro. * txr.1: Documented.
* Adding whena macro.Kaz Kylheku2017-02-051-1/+3
| | | | | | | | | | We have ifa and conda; whena is conspicuously absent. * lisplib.c (ifa_set_entries): Add autoload entry for whena. * share/txr/stdlib/ifa.tl (whena): New macro. * txr.1: Documented whena.
* bugfix: forgotten autoload registrations.Kaz Kylheku2017-01-261-1/+2
| | | | * lisplib.c (except_set_entries): Add catch* and handle*.
* Support keyword params via :key param list macro.Kaz Kylheku2017-01-231-0/+18
| | | | | | | | | | | | | | | | | | * eval.c (expand_param_macro): Use lisplib_try_load to retry failed parameter macro lookup, thereby supporting auto-loading of modules that define parameter macros. * lisplib.c (keyparams_set_entries, keyparams_instantiate): New static functions. (lisplib_init): Support autoloading of keyparams.tl via new functions. * share/txr/stdlib/keyparams.tl: New file. * txr.1: Documented :key param list macro. * checkman.txr: Support "Parameter list macro" documentation section type.
* Bump copyright year to 2017.Kaz Kylheku2017-01-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, 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, ftw.c, ftw.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, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/except.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.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: Add 2017 to all copyright headers and strings.
* Functions for error reporting out of macros.Kaz Kylheku2017-01-151-0/+18
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Register sys:ctx-form and sys:ctx-name intrinsics. * lisplib.c (error_set_entries, error_instantiate): New static functions. (lisplib_init): Register autoloading of error.tl via new functions. * share/txr/stdlib/error.tl: New file. * struct.c (make_struct_type): Purge deferred warnings. * unwind.c (uw_late_init): Register purge-deferred-warning intrinsic.
* New Lisp feature: param list expander.Kaz Kylheku2017-01-041-0/+17
| | | | | | | | | | | | | | | | | | | | | * eval.c (pm_table): New static variable. (expand_param_macro): New static function. (expand_params): Expand parameter list macros via expand_param_macro. (eval_init): gc-protect pm_table and initialize it. Register *param-macro* variable. * lisplib.v (pmac_set_entries, pmac_instantiate): New static functions. (lisplib_init): Register autoloading of pmac.tl via new functions. * share/txr/stdlib/pmac.tl: New file. * txr.1: Notes under defun, lambds, flet/labels and defmacro about the existence of parameter macros which add to the syntax. New Parameter List Macros section. Documented *param-macro* and define-param-expander.
* Bugfix: repeated expansion of catch unstable.Kaz Kylheku2016-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out we have a silly problem: catch is a special operator, which undergoes a macro-like expansion which alters its syntax, but uses the same operator symbol. We turn catch into a macro which expands to a sys:catch operator. * eval.c (sys_catch_s): New symbol variable. (expand_catch): Function now expands sys:catch forms without altering any syntax. (do_expand): Check for sys:catch rather than catch. Call expand_catch differently: it takes the form now instead of just the arguments, so it can return the original form if no expansion takes place. (eval_init): Initialize sys_catch_s variable. Change registration of op_catch to sys:catch symbol. * lisplib.c (except_set_entries): Add catch to the list of autoload symbols for except.tl. * share/txr/stdlib/except.tl (catch): New macro for transforming catch to sys:catch. * txr.1: Reclassify catch operator as a macro.
* Adding prog and prog* macros.Kaz Kylheku2016-12-131-1/+1
| | | | | | | | | * lisplib.c (tagbody_set_entries): Add prog and prog* to autoload list. * share/txr/stdlib/tagbody.tl (prog, prog*): New macros. * txr.1: Documented.
* Expander warns about unbound variables.Kaz Kylheku2016-11-261-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_exception): New static function. (eval_error): Reduced to wrapper around eval_exception. (eval_warn): New function. (me_op): Bind the rest symbol in a shadowing env to suppress watnings about unbound rest. (do_expand): Throw a warning when a bindable symbol is traversed that has no binding. (expand): Don't install atoms as last_form_expanded. * lib.c (warning_s, restart_s, continue_s): New symbol variables. (obj_init): Initialize new symbol variables. * lib.h (warning_s, restart_s, continue_s): Declared. * lisplib.c (except_set_entries): New entries for ignwarn and macro-time-ignwarn. * parser.c (repl_warning): New static function. (repl): Use repl_warning function as a handler for warning exceptions: to print their message and then continue by throwing a continue exception. * parser.y (warning_continue): New static function. (parse_once): Use warning_continue to ignore warnings. In other words, we suppress warnings from Lisp that is mixed into TXR pattern language code, because this produces too many false positives. * share/txr/stdlib/except.tl (ignwarn, macro-time-ignwarn): New macros. * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander): Ignore warnings around calls to sys:expand, because of some gensym-related false positives (we expand code into which we inserted some gensyms, without having inserted the constructs which bind them. * tests/011/macros-2.txr: Suppress unbound variable warnings from a test case. * tests/012/ifa.tl: Bind unbound x y variables in one test case. * tests/012/struct.tl: Suppress unbound variable warnings in some test cases. * uwind.c (uw_throw): If a warning is unhandled, then print its message with a "warning" prefix and then throw a continue exception. (uw_register_subtype): Eliminate the check for sub already being a subtype of sup. This allows us to officially register new types against t. (uw_late_init): Register continue exception type as a subtype of the restart type. Formally register warning type. * txr.1: Documented ignwarn.
* Adding a tagbody macro to the language.Kaz Kylheku2016-11-181-0/+17
| | | | | | | | | | | | | | | | | | | | | | | This is a "disciplined goto" feature of Common Lisp. This uses a new sys:switch operator, which could also be used for optimizing case and cond forms. * eval.c (switch_s): New symbol variable. (op_switch, expand_list_of_form_lists, expand_switch): New static functions. (do_expand): Hook in the expansion of the sys:switch operator. (eval_init): Initialize switch_s special variable to sys:switch symbol. Register sys:switch special op. * lisplib.c (tagbody_set_entries, tagbody_instantiate): New static functions. (lisplib_init): Register autoloading of tagbody module via new functions. * share/txr/stdlib/tagbody.tl: New file. * txr.1: Documented.
* New in-package macro.Kaz Kylheku2016-11-141-1/+1
| | | | | | | | | * lisplib.c (package_set_entries): Add in-package symbol name to autload list. * share/txr/stdlib/package.tl (in-package): New macro. * txr.1: Documented.
* New functions for command or file I/O in one call.Kaz Kylheku2016-11-131-0/+22
| | | | | | | | | | | | | | | | * lisplib.c (getput_set_entries, getput_instantiate): New static functions. (dlt_register): Register auto-loading for getput module via new functions. * share/txr/stdlib/getput.tl: New file. * txr.1: Documented new functions file-get, file-put, file-append, file-get-string, file-put-string, file-append-string, file-get-lines, file-put-lines, file-append-lines, command-get, command-put, command-get-string, command-put-string, command-get-lines, and command-put-lines.
* Add defpackage macro.Kaz Kylheku2016-11-111-0/+19
| | | | | | | | | | | * lisplib.c (package_set_entries, package_instantiate): New static functions. (lisplib_init): Register auto-loading for new package.tl file using new functions. * share/txr/stdlib/package.tl: New file. * txr.1: Documented.
* Implement *package* special var; package overhaul.Kaz Kylheku2016-11-081-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (load): Rebind *package* in the local dynamic environment already established for the sake of *load-path*. By doing this we cause *package* to be restored to its prior value, which allows the loaded file to alter it. Common Lisp works this way. (eval_init): Register *package* variable, with the user package as its default value. * lib.c (package_s): New symbol variable. (intern, rehome_sym): Default the package argument to the current package, not to user_package. (get_user_package, get_system_package, get_keyword_package): Functions removed. (get_current_package): New function. (obj_print_impl): Revise symbol printing. Keyword and uninterned symbols are printed with : and #: prefixes. The remainder are printed with a package prefix if their home package isn't the current package. * lib.h (keyword_package, user_package, system_package): These macros are just straight aliases for the global variables, not going through the lookup mechanism, which was pointless. (cur_package): New macro. (package_s): Declared. (get_current_package): Declared. * lisplib.c (lisplib_try_load): Establish a local dynamic environment, and bind the *package* variable to the user package which the library modules expect. * parser.c (find_matching_syms, provide_completions): Treat unqualified symbols in the current package rather than user package. * parser.y (sym_helper): Intern unqualified symbols in the current package, not user package. * txr.1: Document that the variables user-package, system-package and keyword-package should not be modified. Document the *package* special variable, and that intern and rehome-sym default their package argument to its value. (Here we get rid of wrong references to the undocumented variable *user-package*).
* Introducing command line option processing system.Kaz Kylheku2016-11-031-0/+19
| | | | | | | | | | | * lisplib.c (getopts_set_entries, getopts_instantiate): New functions. (lisplib_init): Register auto-loading for getopt.tl via new functions. * share/txr/stdlib/getopts.tl: New file. * txr.1: Documented new library area.
* Adding function tracing support.Kaz Kylheku2016-10-291-0/+16
| | | | | | | | | | | | | New variable *trace-output*, and macros trace and untrace. * lisplib.c (trace_set_entries, trace_instantiate): new static functions. (dlt_register): Register new functions to auto-load trace module. * share/txr/stdlib/trace.tl: New file. * txr.1: Documented.
* Adding family slot to socket addresses.Kaz Kylheku2016-10-131-1/+1
| | | | | | | | | | | | | | | A static slot indicating the address family simplifies code which wants to map a socket address to its family. * lisplib.c (sock_instantiate): Call sock_load_init before loading socket.tl rather than after, because socket.tl now references variables defined inside sock_load_init. * share/txr/stdlib/socket.tl (sockaddr, sockaddr-in, sockaddr-in6, sockaddr-un): New static slot, family. * txr.1: Documented family slots.
* Synchronize license comments with LICENSE.Kaz Kylheku2016-10-011-16/+17
| | | | | | | | | | | | | | | | | | | | * 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, ftw.c, ftw.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/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.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/socket.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/termios.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, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
* New library feature: imperative list building.Kaz Kylheku2016-09-201-0/+19
| | | | | | | | | | | * lisplib.c (build_set_entries, build_instantiate): New static functions. (dlt_register): Register dynamic loading of build.tl via the two new functions. * share/txr/stdlib/build.tl: New file. * txr.1: Documented everything.
* New place-mutating macro: upd.Kaz Kylheku2016-09-141-1/+1
| | | | | | | | * lisplib.c (place_set_entries): Add upd to the auto-load list for place.tl. * share/txr/stdlib/place.tl (upd): New macro. * txr.1: Documented.
* New alet macro.Kaz Kylheku2016-09-111-1/+1
| | | | | | | | | * lisplib.c (place_set_entries): Add alet symbol to autoload list for place.tl. * share/txr/stdlib/place.tl (alet): New macro. * txr.1: Documented alet.
* New slet macro.Kaz Kylheku2016-09-081-1/+1
| | | | | | | | | | | | | | | | * lisplib.c (place_set_entries): Add slet symbol to autoload list for place.tl. * share/txr/stdlib/place.tl (sys:r-s-let-expander): New function. (rlet): Replace body with call to sys:r-s-let-expander. (slet): New macro. * txr.1: Clarification and corrections in rlet description and example. rlet will in fact handle the three-variable rotation case because, since a is not a constant expression, (rlet ((temp a)) ...) reduces to let. Documented new slet.
* Awk comes to TXR via a macro.Kaz Kylheku2016-09-071-0/+18
| | | | | | | | | * lisplib.c (awk_set_entries, awk_instantiate): New static functions. (lisplib_init): Register auto-loading for awk module via new functions. * share/txr/stdlib/awk.tl: New file.
* New rslot macro to suport upcoming awk macro.Kaz Kylheku2016-09-071-1/+1
| | | | | | | | | | | | This provides a way to create lexical macros denoting slots, such that method are invoked when they are updated. * lisplib.c (struct_set_entries): Add rslot to list of auto-load symbols for struct.tl module. * share/txr/stdlib/struct.tl (sys:rslotset): New function. (rslot, rslot): New macro and place macro. (sys:rslot): New place kind.
* The stdlib variable gets a trailing slash.Kaz Kylheku2016-06-051-14/+14
| | | | | | | | | | | | | | | | | | | * txr.c (sysroot_init): Add slash to stdlib_path. (sysroot_compat_fixup): Replace user-visible stdlib variable with a path that doesn't have a slash, if compatibility is 143 or lower. (compat): Call sysroot_compat_fixup. * lisplib.c (place_set_entries, ver_set_entries, ifa_set_entries, txr_case_set_entries, with_resources_set_entries, path_test_set_entries, struct_set_entries, with_stream_set_entries, hash_set_entries, except_set_entries, type_set_entries, yield_set_entries, sock_set_entries, termios_set_entries): Remove slash from format string since the directory includes it. * txr.1: Added note under stdlib about the slash, and also an entry COMPATIBILITY.
* Adding termios support.Kaz Kylheku2016-05-181-1/+27
| | | | | | | | | | | | | | | | * Makefile (termios.o): New object file. * lib.c (init): Call termios_init. * lisplib.c (termios_set_entries, termios_instantiate): New functions. (lisplib_init): Register new functions in autoload table. * share/txr/stdlib/termios.tl: New file. * termios.c, termios.h: New files. * txr.1: Documented termios.
* Somew new path access testing functions.Kaz Kylheku2016-05-041-1/+4
| | | | | | | | | | | | | | * lisplib.c (path_test_set_entries): New elements in the list for path-readable-to-me-p, path-read-writable-to-me-p, and path-strictly-private-to-me-p. * share/txr/stdlib/path-test.pl (sys:path-access): Test bitwise combinations of permissions, so read+write can be tested in one call. (path-readable-to-me-p, path-read-writable-to-me-p, path-strictly-private-to-me-p): New functions. * txr.1: Documented.
* Macros obtain* and obtain*-block.Kaz Kylheku2016-04-151-0/+1
| | | | | | | | | | * lisplib.c (yield_set_entries): Add obtain* and obtain*-block to autoload list. * share/txr/stdlib/yield.tl (obtain*, obtain*-block): New macros. * txr.1: Documented.