summaryrefslogtreecommitdiffstats
path: root/lisplib.c
Commit message (Collapse)AuthorAgeFilesLines
* opip, oand: rewrite in Lisp.Kaz Kylheku2018-07-161-0/+1
| | | | | | | | | | | | | | | | | * eval.c (opip_s, oand_s, chain_s, chand_s): Variables removed. (me_opip): Function removed. (eval_init): Initializations of removed variables removed. chain and chand symbols interned at point of function registration. * lisplib.c (op_set_entries): Add autoload entries for opip and oand. * share/txr/stdlib/op.tl (sys:opip-expand): New function. (opip, oand): New macros. * protsym.c: Regenerated.
* op: convert to Lisp trivial macros related to op.Kaz Kylheku2018-07-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The op macro is no longer written in C, but the trivial macros ap, ip, ado, ido, ret and aret are still C. It's silly to have macros written in C, baked into the TXR executable, which just produce syntax for a complicated macro written in Lisp that must be autoloaded when that code is used. * eval.c (ap_s, apf_s, ipf_s, ret_s, aret_s): Variables removed. (me_ap, me_ip, me_ado, me_ido, me_ret_aret): Functions removed. (eval_init): Do not initialize removed variables. Remove registration for macros ap, ip, ado, ido, ret and aret. Intern the apf and ipf symbols in the same expression which registers these functions. * lisplib.c (op_set_entries): Add autoload entries for ap, ip, ado, ido, ret and aret. * share/txr/stdlib/op.tl (ap, ip, ado, ido, ret, aret): New macros. * protsym.c: Regenerated.
* awk: bugfix: autoload on sys:awk-state.Kaz Kylheku2018-05-231-0/+4
| | | | | | | | | | | | The problem is that compiled code which uses the awk macro won't load because it invokes make-struct for the unknown sys:awk-state type. Interpreted code doesn't have the problem because it has to expand the awk macro from scratch to generate the make-struct call, and the awk macro triggers the autoload. * lisplib.c (awk_set_entries): Add sys:awk-state to autoload list for awk.tl.
* autoload: few autoload entries needed.Kaz Kylheku2018-04-241-1/+22
| | | | | | | | | | | | | | | | | | With the advent of compiled code, problems are exposed in the autoloader. We can no longer rely on the reference to a macro to load a dependent module. Macros go away during compiling, leaving behind functions. References to those functions have to trigger autoloading. * lisplib.c (place_set_entries): Add new table of sys: functions, containing sys:get-fun-getter-setter, sys:get-mb, sys:get-vb and sys:register-simple-accessor. These seem to be all the macro run-time-support functions in place.tl. (struct_set_entries): Add sys:rslotset. (yield_set_entries): Add sys:obtain-impl. (trace_set_entries): Add sys:trace and sys:untrace. (keyparams_set_entries): Add sys:extract-keys.
* compiler: streamline destructuring error checks.Kaz Kylheku2018-04-231-1/+2
| | | | | | | | | | | | | * lisplib.c (error_set_entries): Add sys:bind-mac-check to autoload list for error.tl * compiler.tl (expand-bind-mac-params): For strict mode, use the new sys:bind-mac-check function to do the check and report the error. For non-strict checks, consolidate the error check by taking advantage of n-ary nature of <= function. * error.tl (sys:bind-mac-check): New function.
* new macros: hlet, hlet*.Kaz Kylheku2018-04-191-1/+1
| | | | | | | | | | * lisplib.c (yield_set_entries): Add hlet and hlet* to autoload list. * share/txr/stdlib/yield.tl (hlet-expand): New function (hlet, hlet*): New macros. * txr.1: Documented.
* compiler: lambda call to let optimization.Kaz Kylheku2018-04-151-1/+2
| | | | | | | | | | | | | | | | | | | Normalize ((lambda ...) args) to (call (lambda ...) args). Reduce (apply (lambda ...) args) and (call (lambda ...) args) to let (let (vars-inited-from-args ...) ...). * lisplib.c (error_set_entries): Autoload for new error functions lambda-too-many-args, lambda-too-few-args, lambda-short-apply-list. * share/txr/stdlib/compiler.tl (comp-fun-form): Restructure to recognize lambda and handle via comp-inline-lambda. (compiler comp-inline-lambda): New method. (lambda-apply-transform): New function. * share/txr/stdlib/error.tl (lambda-too-many-args, lambda-too-few-args, lambda-short-apply-list): New functions.
* compiler: implement with-compilation-unit macro.Kaz Kylheku2018-04-091-0/+1
| | | | | | | | | | | | * lisp.c (compiler_set_entries): Add with-compilation-unit to autoload symbols for compile module. * share/txr/stdlib/compiler.tl (usr:with-compilation-unit): New macro. (usr:compile-file): Use with-compilation-unit macro to dump warnings if a file is processed alone. * txr.1: Documented.
* new function: compile.Kaz Kylheku2018-04-071-1/+1
| | | | | | * lisplib.c (compiler_set_entries): Add compile to autoloads. * share/txr/stdlib/compiler.tl (usr:compile): New function.
* stdlib: all code read under sys package.Kaz Kylheku2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Another part of the preparation for an upcoming change. All library code is now read in the sys package, so any symbols that are interned (local variables and whatnot) are in sys and will not be exposed to user code. We have to overcome some annoyances to achieve this: - We have to stay away from the symbols exp or var, because they are now sys:exp and sys:var with their special meaning. - Instances in which a symbol of the same name exists in both sys and usr present a problem; the plain symbol now is the usr one. For instance rplaca will refer to sys:rplaca, so a small amount of code has to explicitly use usr:rplaca. * Makefile (COMPILE_TL): Change to the sys package before compiling library code. * lisplib.c (lisplib_try_load): Bind *package* to the system package. * share/txr/stdlib/asm.tl, share/txr/stdlib/compiler.tl: Remove in-package macro invocation; we don't need this since all files are loaded or compiled in the sys package. * 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/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/trace.tl share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/ver.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl: Deal with the various usr versus sys symbol issues.
* autoload: add more missing symbols.Kaz Kylheku2018-04-061-1/+12
| | | | | | | | | | | | If user code interns these symbols before the autoload takes place, things will misbehave. For instance if user code interns a symbol called "rng" in its own package, not usr, and then awk is loaded, then using (rng ...) in that awk macro won't work. * lisplib.c (ifa_set_entries): Add the it symbol. (awk_set_entries): Add numerous symbols to the intern list: all of the awk special variables and awk functions/macros.
* autoload: smattering of missing/wrong entries.Kaz Kylheku2018-04-061-1/+4
| | | | | | | * lisplib.c (place_set_entries): add missing pinc and pdec. Fix misspelled define-accessor. (sock_set_entries): Add missing iinaddr-any, inaddr-loopback, in6addr-any and in6addr-loopback.
* autload: remove copy and pasted sock_load_init calls.Kaz Kylheku2018-04-061-3/+0
| | | | | | | * lisplib.c (termios_instantiate, awk_instantiate, build_instantiate): Remove sock_load_init calls which make no sense in these functions. This is the result of flurried copy and pasting.
* compiler: move sys:bind-mac-error to error.tl.Kaz Kylheku2018-04-041-1/+6
| | | | | | | | | | | | | | | | | | | | | | | The sys:bind-mac-error function is a run-time support function for the compiler-generated code for destructuring. But the compiler.tl source file is a bad place for it. It means that compiled modules which need sys:bind-mac-error auto-load the entire compiler. That easily creates an irresolveable cycle, because the compiler is on top of the foodchain. No, sys:bind-mac-error belongs in error.tl; the light-weight module of low-dependency run-time support routines for error reporting. * lisplib.c (error_set_entries): Add sys:bind-mac-error symbol here. (compiler_set_entries): Remove it from here. * share/txr/stdlib/compiler.tl (sys:bind-mac-error): Function removed. * share/txr/stdlib/error.tl (sys:bind-mac-error): Function moved here.
* struct: autoload sys:define-method.Kaz Kylheku2018-04-041-0/+4
| | | | | | | | | | Compiled code references sys:define-method directly without going through the struct macrology that would otherwise trigger the autoload of the struct stuff. The symbol needs to be added to the set of triggers. * lisplib.c (struct_set_entries): Add sys:define-method symbol.
* autoload: don't refer to .tl files specifically.Kaz Kylheku2018-04-041-30/+30
| | | | | | | | | | | | | | | | | | | | | | | We would like to load the compiled versions of the library files, if they exist, in preference to the source versions. So we want to issue loads without the .tl suffix; let the load function sort it out. * gencadr.c (cadr_register): Drop .tl suffix. * lisplib.c (place_instantiate, ver_instantiate, ifa_instantiate, txr_case_instantiate, with_resources_instantiate, path_test_instantiate, struct_instantiate, with_stream_instantiate, hash_instantiate, except_instantiate, type_instantiate, yield_instantiate, termios_instantiate, awk_instantiate, build_instantiate, trace_instantiate, getopts_instantiate, package_instantiate, getput_instantiate, tagbody_instantiate, pmac_instantiate, error_instantiate, keyparams_instantiate, ffi_instantiate, doloop_instantiate, stream_wrap_instantiate, asm_instantiate, compiler_instantiate, op_instantiate): Likewise. * cadr.c: Regenerated.
* compiler: first cut compile-file implementation.Kaz Kylheku2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | * lisplib.c (compiler_set_entries): Autoload on compile-file. * parser.c (parse_init): Expose get-parser, parser-errors and parser-eof intrinsics in system package. * share/txr/stdlib/compiler.tl (compiler): Wrap defstruct form in compile-only. What this means is that when we invoke comile-file on compiler.tl, the compiler will only compile this defstruct and not evaluate it. I.e. it will not try to redefine the structure. Redefining the core structure of the compiler while it is compiling itself wreaks havoc on the compilation. (%fille-suff-rx%, *emit*, *eval*): New variables. (open-compile-streams, list-from-vm-desc, usr:compile-file): New functions. * vm.c (vm_desc_nlevels, vm_desc_nregs): New static functions. (vm_init): Register new intrinsics vm-desc-nlevels and vn-desc-nregs in system package.
* compiler: auto-load sys:bind-mac-error.Kaz Kylheku2018-03-231-1/+1
| | | | | | | This is run-time support needed by compiled tree-bind code. * lisplib.c (compiler_set_entries): Add bind-mac-error to sys package auto-load list.
* Adding compiler.Kaz Kylheku2018-03-161-0/+23
| | | | | | | | | * lisplib.c (compiler_instantiate, compiler_set_entries): New static functions. (lisplib_init): Register auto-load for compiler via new functions. * share/txr/stdlib/compiler.tl: New file.
* higher level disassemble function.Kaz Kylheku2018-03-131-2/+7
| | | | | | | | | | | | | | | | * lisplib.c (asm_set_entries): Autoload on usr:disassemble. * share/txr/stdlib/asm.tl (assembler): Drop initializer from bstr slot. Requires complex initialization for the case when the buf is supplied by the constructor caller for the sake of disassembling existing code. (assembler :postinit): Handle cases when only one of buf or bstr are set, and when both are not set, for the greatest flexibility. (disassemble-c-d, disassemble): New functions. * vm.c (vm_desc_datavec): New static function. (vm_init): Registered vm-desc-datavec intrinsic.
* New: virtual machine with assembler.Kaz Kylheku2018-03-101-2/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is the start of compiler work to make TXR Lisp execute faster. In six days of part time work, we now have a register-style virtual machine with 32 instructions, handling exceptions, unwind-protect, lexical closures, and global environment access/mutation. We have a complete assembler and disassembler for this machine. The assembler supports labels with forward referencing with backpatching, and features pseudo-ops: for instance the (mov ...) pseudo-instruction chooses one of three kinds of specific move instruction based on the operands. * Makelfile (OBJS): Add vm.o. * eval.c (lookup_sym_lisp1): Static function becomes external; the virtual machine needs to use this to support that style of lookup. * genvmop.txr: New file. This is the generator for the "vmop.h" header. * lib.c (func_vm): New function. (generic_funcall): Handle the FVM function type via new vm_execute_closure function. In the variadic case, we want to avoid the argument copying which we do for the sake of C functions that get their fixed arguments directly, and then just the trailing arguments. Thus the code is restructured a bit in order to switch twice on the function type. (init): Call vm_init. * lib.h (functype_t): New enum member FVM. (struct func): New member in the .f union: vm_desc. (func_vm): Declared. * lisplib.c (set_dlt_entries_impl): New static function, formed from set_dlt_entries. (set_dlt_entries): Reduced to wrapper for set_dlt_entries_impl, passing in the user package. (set_dlt_entries_sys): New static function: like set_dlt_entries but targetting the sys package. (asm_instantiate, asm_set_entries): New static functions. (lisplib_init): Auto-load the sys:assembler class. * share/txr/stdlib/asm.tl: New file. * vm.c, vm.h, vmop.h: New files.
* 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.