summaryrefslogtreecommitdiffstats
path: root/lib.h
Commit message (Collapse)AuthorAgeFilesLines
* lib: new ldiff function.Kaz Kylheku2018-03-201-0/+3
| | | | | | | | | | * eval.c (eval_init): Use the old ldiff function under compatibility with 190 or lower. * lib.c (ldiff): Rewritten. (ldiff_old): New function, copy of previous version of ldiff. * lib.h (ldiff_old): Declared.
* New: virtual machine with assembler.Kaz Kylheku2018-03-101-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Require semicolon after static_{forward,def} macros.Kaz Kylheku2018-02-261-2/+2
| | | | | | | | | | | * lib.h (static_forward, static_def): At least the C version of these now require a trailing semicolon. * struct.c (struct_type_ops): Add required semicolon after static_def. * syslog.c (syslog_strm_ops): Add required semicolon after static_forward and after static_def.
* 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.
* term: move near site of use.Kaz Kylheku2018-01-071-1/+0
| | | | | | | | | * eval.c (term): Function here from lib.c, and changed to static. It is used only by iapply. * lib.c (term): Function moved to eval.c. * lib.h (term): Declaration removed.
* listref_l: remove.Kaz Kylheku2018-01-061-1/+0
| | | | | | * lib.c (listref_l): Unused function removed. * lib.h (listref_l): Declaration removed.
* ltail: unused function.Kaz Kylheku2018-01-021-1/+0
| | | | | | | | * lib.c (ltail): Function removed. This was introduced at the same time as lazy_appendv and used only by it. That function was rewritten a few months ago and doesn't use lail. * lib.h (ltail): Declaration removed.
* eliminate cdr_l use from implementation of last.Kaz Kylheku2018-01-021-1/+1
| | | | | | * lib.c (lastcons): Return value is just the last cons rather than a loc. The only caller of this function is last. (last): Adapt to the new lastcons.
* New methods rplaca and rplacd.Kaz Kylheku2017-12-301-0/+1
| | | | | | | | | | | | | | | * eval.c (eval_init): Register rplaca and rplacd using new rplaca_s and rplacd_s symbol variables. * lib.c (rplaca_s, rplacd_s): New symbol variables. (rplaca): Handle struct object via rplaca method, if it has one, otherwise lambda-set, if it has that, or else error out. (rplacd): Handle struct object via rplacd method. * lib.h (rplaca_s, rplacd_s): Declared. * txr.1: Documented rplaca and rplacd methods.
* prof: deal with overflowing mem counters.Kaz Kylheku2017-12-041-0/+2
| | | | | | | | * eval.c (op_prof): Deal with the cases when alloc_bytes_t value cannot be converted to a val in a single call to unum. * lib.h (SIZEOF_ALLOC_BYTES_T): New macro.
* New function: grade.Kaz Kylheku2017-11-231-0/+1
| | | | | | | | | | | | Inspired by APL. * eval.c (eval_init): Register grade intrinsic. * lib.c (grade): New function. * lib.h (grade): Declared. * txr.1: Documented.
* bugfix: fixnum crackdown.Kaz Kylheku2017-09-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The purpose of this commit is to address certain situations in which code is wrongly relying on a cnum value being in the fixnum range (NUM_MIN to NUM_MAX), so that num_fast can safely be used on it. One wrong pattern is that c_num is applied to some Lisp value, and that value (or one derived from it arithmetically) is then passed to num_fast. The problem is that c_num succeeds on integers outside of the fixnum range. Some bignum values convert to a cnum successfully. Thus either num has to be used instead of num_fast, or else the original c_num attempt must be replaced with something that will fail if the original value isn't a fixnum. (In the latter case, any arithmetic on the fixnum cannot produce value outside of that range). * buf.c (buf_put_bytes): The size argument here is not guaranteed to be in fixnum range: use num. * combi.c (perm_init_common): Throw if the sequence length isn't a fixnum. Thus the num_fast in perm_while_fun is correct, since the ci value is bounded by k, which is bounded by n. * hash.c (hash_grow): Remove dubious assertion which aborts the run-time if the hash table doubling overflows. Simply don't allow the modulus to grow beyond NUM_MAX. If doubling it makes it larger than NUM_MAX, then just don't grow the table. We need the modulus to be in fixnum range, so that uses of num_fast on the modulus value elsewhere are correct. (group_by, group_reduce): Use c_fixnum rather than c_num to extract a value that is later assumed to be a fixnum. * lib.c (c_fixnum): New function. (nreverse, reverse, remove_if, less, window_map_list, sort_vec, unique): Use c_fixnum rather than c_num to extract a value that is later assumed to be a fixnum. (string_extend): Use c_fixnum rather than c_num to extract a value that is later assumed to be a fixnum. Cap the string allocation size to fixnum range rather than INT_PTR_MAX. (cmp_str): The wcscmp function could return values outside of the fixnum range, so we must use num, not num_fast. * lib.h (c_fixnum): Declared.
* Revising out-of-memory handling.Kaz Kylheku2017-08-181-4/+2
| | | | | | | | | | | | | | | | | | | | | We don't want to be aborting on OOM, but throwing an exception. * lib.c (alloc_error_s): New symbol variable. (oom_realloc): Global variable removed. (oom): New static function. (chk_malloc, chk_malloc_gc_more, chk_calloc, chk_realloc): Call oom instead of removed oom_realloc handler. (env): Throw alloc-error rather than error by calling oom. (obj_init): Initialize alloc_error_s. (init): Drop function pointer argument; do not initialize removed oom_realloc. * lib.h (alloc_error_s): Declared. (oom_realloc): Declaration removed. (init): Declaration updated. * txr.1: Type tree diagram includes alloc-error.
* New spl and tok: variants of tok-str and split-str.Kaz Kylheku2017-08-071-0/+2
| | | | | | | | * eval.c (eval_init): Register spl and tok intrinsics. * lib.c (spl, tok): New functions. * txr.1: Documented.
* bugfix: n-ary arith functions must check single arg.Kaz Kylheku2017-08-051-1/+3
| | | | | | | | | | | | | | | | We are allowing calls like (* "a") and (+ "a") without diagnosing that the argument isn't of a valid type. Note that (max "a") is fine beacause min and max use the less function; they are not strictly numeric. * lib.c (nary_op): Beef up function with additional argument for type checking the unary case. (unary_num, unary_arith, unary_int): New static functions. (plusv, mulv, logandv, logiorv): Use new nary_op interface. (gtv, ltv, gev, lev, numeqv, numneq): Check the first number. * lib.c (nary_op): Declaration updated.
* Add sum and prod convenience functions.Kaz Kylheku2017-08-051-0/+2
| | | | | | | | | | * eval.c (eval_init): prod and sum intrinsics registered. * lib.c (sum, prod): New functions. * lib.h (sum, prod): Declared. * txr.1: Documented.
* lib: deprecate set-diff; extend set operations.Kaz Kylheku2017-07-261-0/+2
| | | | | | | | | | | | | | * eval.c (eval_init): Register set-diff under two names: set-diff and diff. Register new isec and uni intrinsics. * lib.c (isec, uni): New functions. * lib.h (isec, uni): Declared. * txr.1: Documented new uni and isec functions, new diff function name, and the deprecation of set-diff and its order guarantee w.r.t the left sequence.
* new function: nthKaz Kylheku2017-07-181-0/+1
| | | | | | | | | | | | | | | | Just the ANSI CL nth for lists. * eval.c (eval_init): Register nth intrinsic. * lib.c (nth): New function. * lib.h (nth): Declared. * share/txr/stdlib/place.tl (nth): New place macro, trivially takes care of making nth an accessor. Place macros are terrific! * txr.1: Documented.
* lib: new function, relate.Kaz Kylheku2017-07-171-0/+1
| | | | | | | | | | | * eval.c (eval_init): Register new intrinsic relate. * lib.c (do_relate, do_relate_dfl): New static functions. (relate): New function. * lib.h (relate): Declared. * txr.1: Documented.
* New cptr functions cptr-cast and int-cptr.Kaz Kylheku2017-06-261-0/+2
| | | | | | | | | | | * eval.c (eval_init): Register new intrinsics cptr-cast and int-cptr. * lib.c (cptr_cast, int_cptr): New functions. * lib.h (cptr_cast, int_cptr): Declared. * txr.1: Documented.
* cptr-int and cptr-obj can make typed cptr objects.Kaz Kylheku2017-06-191-2/+2
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Update registration of cptr-int and cptr-obj with one optional argument. * lib.c (cptr_int): New type symbol argument, defaulting to nil. Also, don't bother defaulting the integer argument; the function isn't registered for that being optional. (cptr_obj): New type symbol argument, defaulting to nil. * lib.h (cptr_int, cptr_obj): Declarations updated. * txr.1: Documented cptr-int and cptr-obj function changes. Added discussion of type tag to introductory paragraph. Also added neglected documentation of the FFI cptr type, both unparametrized and parametrized.
* New sequence classification system.Kaz Kylheku2017-06-161-0/+13
| | | | | | | | | | | | This will help simplify writing generic sequence code, while allowing lists and vectors to be handled specially. * lib.h (enum seq_kind, seq_kind_t): New enum and typedef. (struct seq_info, seq_info_t): New struct and typedef. (seq_kind_tab, seq_info): Declared. * lib.c (seq_kind_tab): New global array. (seq_info): New function.
* lib: new chk_xalloc, with mult overflow check.Kaz Kylheku2017-06-121-0/+1
| | | | | | | | | This will simplify code that allocates an array-like object whose size is the product of two numbers. * lib.c (chk_xalloc): New function. * lib.h (chk_xalloc): Declared.
* Splitting cptr object into separate CPTR tag.Kaz Kylheku2017-05-151-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CPTR shares representation and a lot of implementation with COBJ. The COBJ class symbol is the CPTR type tag. There is no hierarchy among CPTR tags. The nil tag is used for a modicum of type looseness, so that we don't straitjacket ourselves too much into this tag-based typing scheme. All existing cptr objects are becoming CPTR, and all get a nil tag, except for dlopen library handles, and dlsym symbols, which are tagged as dlhandle and dlsym. The FFI framework will support tag-declared cptr's. This will help with safety. For instance, suppose an API has half a dozen different kinds of opaque handles. If they are all just cptr on the TXR Lisp side, it's easy to mix them up, passing the wrong one to the wrong C function. * lib.h (enum type): New enum member, CPTR. (cptr_print_op, cptr_typed, cptrp, cptr_type, cptr_handle): Declared. (cptr_addr_of): Parameters added. * lib.c (code2type): Map CPTR type code to cptr_s. (equal): Handle CPTR objects. They are only equal to other CPTR objects which have the same operations, and are equal under the equal function of those operations. (cptr_print_op): New function. (cptr_ops): Use cptr_print_op rather than cobj_print_op. (cptr_typed): New function. (cptr): Use cptr_typed to make a cptr with tag nil, rather than using cobj. (cptrp, cptr_handle, cptr_type): New functions. (cptr_get): Go through cptr_handle rather than cobj_handle. (cptr_addr_of, cptr_zap, cptr_free): Use call to cptr_handle rather than cobj_handle for the type checking side effect. New parameters for type and parent function name. (obj_print_impl): Handle CPTR with same case as COBJ. * gc.c (finalize, mark_obj): Handle CPTR cases using common code with COBJ. * hash.c (equal_hash): Handle CPTR just like COBJ. * eval.c (eval_init): Register cptrp and cptr-type intrinsic functions. * ffi.c (ffi_cptr_put, ffi_cptr_get, ffi_cptr_alloc): Use the potentially type-safe cptr_handle, instead of cptr_get. However, for an untagged cptr, there is no type safety because tft->mtypes is nil. The argument can be any kind of cptr. * sysif.c (dlhandle_s, dlsym_s): New symbol variables. (cptr_dl_ops): Use cptr_print_op. (dlopen_wrap, dlclose_wrap): Use typed cptr with dlhandle as the type. (dlsym_wrap, dlsym_checked, dlvsym_wrap, dlvsym_checked): Recognize only a cptr of type dlhandle for the library. Construct a typed cptr of type dlsym. (sysif_init): Initialize dlhandle_s and dlsym_s. Register dlsym function using dlsym_s.
* less table robust against type renumbering.Kaz Kylheku2017-05-151-1/+1
| | | | | | | | | | * lib.c (less_tab_init): The type_prec table initialization will become incorrect if new type enums are added other than at the end. Let's switch to assignments. Anything not mentioned is zero. * lib.h: Add more advice to comment about extending type_t: consider all places where MAX_TYPE is used.
* bugfix: use proper hashing for cptr.Kaz Kylheku2017-05-151-0/+1
| | | | | | | | | | | | | | | Since cptr objects are equal if their handles are equal, they must have a hashing function over the handle rather than over their own address. * lib.c (cobj_handle_hash_op): New function. (cptr_ops): Use cobj_handle_hash_op instead of cobj_eq_hash_op. * lib.h (cobj_handle_hash_op): Declared. * sysif.c (cptr_dl_ops): Use cobj_handle_hash_op instead of cobj_eq_hash_op.
* cobj: rename poorly named default operation.Kaz Kylheku2017-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Renaming cobj_hash_op to cobj_eq_hash_op. This function is only appropriate to use with COBJ objects which use eq as their equal funtion. I've spotted one instance of an inappropriate use which have to be addressed by a different commit: the equal function is other than eq, but cobj_hash_op is used for the equal hash. * lib.h (cobj_hash_op): Declaration renamed to cobj_eq_hash_op. * hash.c (cobj_hash_op): Renamed to cobj_eq_hash_op. (hash_iter_ops): Refer to renamed cobj_hash_eq_op. * ffi.c (ffi_type_builtin_ops, ffi_type_struct_ops, ffi_type_ptr_ops, ffi-closure_ops, ffi_call_desc_ops): Likewise. * lib.c (cptr_ops): Likewise. * parser.c (parser_ops): Likewise. * rand.c (random_state_ops): Likewise. * regex.c (char_set_ops, regex_obj_ops): Likewise. * socket.c (dgram_strm_ops): Likewise. * stream.c (null_ops, stdio_ops, tail_ops, pipe_ops, dir_ops, string_in_ops, byte_in_ops, strlist_in_ops, string_out_ops, strlist_out_ops, cat_stream_ops, record_adapter_ops): Likewise. * struct.c (struct_type_ops): Likewise. * sysif.c (cptr_dl_ops): Likewise. * syslog.c (syslog_strm_ops): Likewise. * unwind.c (cont_ops): Likewise.
* cptr: new functions.Kaz Kylheku2017-05-091-0/+4
| | | | | | | | | | * eval.c (eval_init): Register cptr-int, ctpr-obj, cptr-zap and cptr-free functions and cptr-null variable. * lib.c (cptr_int, cptr_obj, cptr_zap, cptr_free): New functions. * lib.c (cptr_int, cptr_obj, cptr_zap, cptr_free): Declared.
* ffi: map (array n bchar) to Lisp string.Kaz Kylheku2017-05-041-0/+1
| | | | | | | | | | * ffi.c (struct txr_ffi_type): New bitfield flag, bchar_conv. (ffi_array_in, ffi_array_get): Handle bchar_conv. (ffi_type_compile): Set bchar_conv flag for array of bchar. * lib.c (string_8bit_size): New function. * lib.h (string_8bit_size): Declared.
* ffi: new bstr type.Kaz Kylheku2017-05-041-0/+2
| | | | | | | | | | | | | | | | | | The bstr type is like str, but doesn't perform UTF-8 conversion. The C data is assumed to be null terminated byte strings representing code points U+0000 through U+00FF. * ffi.c (bstr_s, bstr_d_s): New symbol variables. (ffi_bstr_put, ffi_bstr_get, ffi_bstr_d_get): New static functions. (ffi_init_types): Register bstr and bstr-d types. (ffi_init): Initialize bstr_s and bstr_d_s. * ffi.h (bstr_s, bstr_d_s): Declared. * lib.c (chk_strdup_8bit, string_8bit): New function. * lib.h (chk_strdup_8bit, string_8bit): Declared.
* ffi: allow ptr-in-out passing of cptr.Kaz Kylheku2017-04-281-0/+1
| | | | | | | | | | | | | | | * ffi.c (ffi_ptr_alloc): New static function. (ffi_type_compile): Give the cptr type alloc and free functions: alloc just retrives the address of the pointer inside the cptr object (pointer to pointer); free is a noop. (cptr_make): New static function. (ffi_init): Register cptr_make as cptr intrinsic. Register cptr-null intrinsic variable denoting a ready-made null pointer. * lib.c (cptr_addr_of): New function. * lib.h (cptr_addr_of): Declared.
* Provide access to dlopen.Kaz Kylheku2017-04-251-0/+1
| | | | | | | | | | | | | | | | | | | | * configure: New test for dlopen. * lib.c (cptr_equal_op): Function renamed to cobj_equal_handle_op, to reflect what it's really doing; it is not specifically to cptr objects. Also changed from static to extern. (cptr_ops): Follow rename. * lib.h (cobj_equal_handle_op): Declared. * sysif.c (cptr_dl_destroy_op): New static function. (dlopen_wrap, dlclose_wrap, dlsym_wrap, dlvsym_wrap): New static functions. (sysif_init): Register new intrinsic functions dlopen, dlclose, dlsym, dlvsym. New variables rtld-lazy, rtld-now, rtld-global, rtld-local, rtld-nodelete, rtld-noload, rtld-deepbind.
* Rename c_uint_ptr_num; introduce cunum typedef.Kaz Kylheku2017-04-211-0/+1
| | | | | | | | | | | | | | | Unsigned version of cnum becomes less verbose. * arith.c (c_uint_ptr_num): Renamed to c_unum. * arith.h (c_uint_ptr_num): Declaration removed. (c_unum): Declared. * itypes.c (c_u32, c_u64, c_uint): Follow rename. * lib.h (ucnum): New typedef. * rand.c (make_random_state): Follow rename.
* New buffer data type.Kaz Kylheku2017-04-161-2/+10
| | | | | | | | | | | | | | | | | | | | | | | Work in progress. * gc.c (finalize): Add cast to switch expression so gcc flags when we are missing one of the enumerations. Handle new BUF enum to free dynamic buffers. (mark_obj): Mark len and size fields of buf, in case they aren't just nil or integers. * hash.c (hash_buf): New static function. (equal_hash): Route BUF type to hash_buf. * lib.c (buf_s): New symbol variable. (code2type): Handle BUF. (equal): Handle BUF using memcmp on the data. (obj_init): Intern buf symbol and initialize buf_s. * lib.h (type_t): New enum member BUF. (struct buf): New type. (union obj): New member b, of struct buf type. (buf_s): Declared.
* New time-parse-local and time-parse-utc functions.Kaz Kylheku2017-04-041-0/+2
| | | | | | | | | | | | | | | * eval.c (eval_init): Register intrinsic functions time-parse-local and time-parse-utc. * lib.c (strptime_wrap): New static function. (time_parse): Now implemented as by call to strptime_wrap. (time_parse_local, time_parse_utc): New functions. These get the time_t time from struct tm without constructing the intermediate Lisp structure. * lib.h (time_parse_local, time_parse_utc): Declared. * txr.1: Documented new functions.
* listener: completion sensitive for slots and methods.Kaz Kylheku2017-03-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When completing .prefix[TAB], .(prefix[TAB] or .[prefix[TAB], restrict identifiers to the appropriate namespace. The former will report only symbols from the relevant package which are struct slots; the latter further restricts it to those which are static slots defined as functions. * lib.c (symbol_visible): Static function becomes extern. * lib.h (symbol_visible): Declared. * parser.c (find_matching_syms): par parameter is renamed kind and can hold additional values 'S' (slots) and 'M' (methods). New get_slot_syms function is used to fetch the slots, as necessary, instead of the visible syms, if the kind is 'S' or 'M'. The same loop as before (with the minor change of recognizing 'S' and 'M' also) performs the prefix matching. (provide_completions): Recognize . .( and .[ prefix, calculating the kind argument of find_matching_syms in a new way. * struct.c (get_slot_syms): New function. * struct.h (get_slot_syms): Declared. * txr.1: Add some notes about this under the description of completion. The full rules are not given though; let the user discover.
* Sandboxing support via *package-alist*.Kaz Kylheku2017-03-171-1/+4
| | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register *package-alist* variable, taking on the contents of the packages variable. * lib.c (package_alist_s): New symbol variable. (make_package, packagep, find_package, package_alist); Work with dynamic package alist variable via cur_package_alist_loc macro. (get_current_package_alist_loc): New function. * lib.h (cur_package_alist_loc): New macro. (packages, package_alist_s, get_current_package_alist_loc): Declared. * txr.1: Documented *package-alist* along with notes about sandboxing. Documented that the package-alist function is now obsolescent.
* Rename badly named default_bool_argKaz Kylheku2017-03-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.h (default_bool_arg): Inline function renamed to default_null_arg. * eval.c (if_fun, pad, ginterate, giterate, range_star, range, constantp, macroexpand_1, macro_form_p, expand_with_free_refs, do_expand, eval_intrinsic, func_get_name, make_env_intrinsic): Follow rename. * arith.c (lognot): Likewise. * gc.c (gc_finalize): Likewise. * glob.c (glob_wrap): Likewise. * hash.c (group_reduce, gethash_n): Likewise. * lib.c (print, multi_sort, lazy_str, vector, iff, tok_str, split_str_keep, search_str, remove_if, val): Likewise. * match.c (match_fun): Likewise. * parser.c (lisp_parse_impl, regex_parse): Likewise. * rand.c (make_random_state): Likewise. * regex.c (read_until_match, search_regex, regex_compile): Likewise. * socket.c (sock_accept, sock_connect): Likewise. * stream.c (open_files_star, open_files, run, open_process, open_tail, get_string, record_adapter): Likewise. * struct.c (static_slot_ensure, static_slot_ens_rec, clear_struct, make_struct_type): Likewise. * sysif.c (exec_wrap, errno_wrap, cobj_ops_init): Likewise. * unwind.c (uw_capture_cont, uw_find_frames_impl): Likewise.
* New functions starts-with and ends-with.Kaz Kylheku2017-03-121-0/+2
| | | | | | | | | | | * eval.c (eval_init): Register starts-with and ends-with intrinsics. * lib.c (starts_with, ends_with): New functions. * lib.c (starts_with, ends_with): Declared. * txr.1: Documented.
* New rmismatch function.Kaz Kylheku2017-03-121-0/+1
| | | | | | | | | | * eval.c (eval_init): Register rmismatch intrinsic. * lib.c (rmismatch): New function. * lib.h (rmismatch): Declared. * txr.1: Documented
* New floor-rem, ceil-rem and round-rem.Kaz Kylheku2017-02-261-1/+4
| | | | | | | | | | | | * arith.c (trunc_rem): Move function to below round function. Make second argument optional, defaulting to one. (floor_rem, ceil_rem, round_rem): New functions. * eval.c (eval_init): Registration of trunc-rem altered for optional argument. New registrations for floor-rem, ceil-rem, round=rem. * txr.1: Documented for new functions folded with trunc-rem.
* Adding round function.Kaz Kylheku2017-02-251-0/+1
| | | | | | | | | | | * arith.c (round1): New static function. (roundiv): New function. * configure: New test for C99 round function. * eval.c (eval_init): Register round intrinsic. * txr.1: Documented.
* floor and ceil do division, with optional second arg.Kaz Kylheku2017-02-241-0/+2
| | | | | | | | | | | | | | | Also, with one argument, these functions handle ranges. * arith.c (floordiv, ceildiv): New functions. (floorf, ceili): Handle ranges. * eval.c (eval_init): Register floor and ceil to new functions. * lib.h (floordiv, ceildiv): Declared. * txr.1: Documentation updated.
* New internal function: vec.Kaz Kylheku2017-02-151-0/+1
| | | | | | * lib.c (vec): New function. * lib.h (vec): Declared.
* Add rassoc and rassql functions.Kaz Kylheku2017-02-111-0/+2
| | | | | | | | | | | * eval.c (eval_init): Register rassoc and rassql intrinsics. * lib.c (rassoc, rassql): New functions. * lib.h (rassoc, rassql): Declared. * txr.1: Documented rassoc and rassql, with small fixes to assql and assoc.
* Use non-hacky representation for deferrable warnings.Kaz Kylheku2017-02-101-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deferrable warnings now get their own subtype, defr-warning. The tag is a regular argument: no funny dotted argument list. * eval.c (eval_defr_warn): Throw new style deferrable warning. (me_op, no_warn_expand): Catch defr-warning rather than warning. Use uw_muffle_warning to suppress it. (gather_free_refs): Parse new representation of deferrable warning. (expand_with_free_refs): Catch defr-warning rather than warning. * lib.c (defr_warning_s): New symbol variable defined. (obj_init): Initialize defr_warning_s. * lib.h (defr_warning_s): Declared. * share/txr/stdlib/error.tl (compile-defr-warning): Throw new-style deferrable warning. * unwind.c (uw_muffle_deferrable_warning): Function removed. (uw_throw): Bugfix: handle warnings by checking by subtype rather than exactly for the warning type. Distinguish deferrable warnings by subtype rather than argument list shape. (uw_defer_warning): Take the new style args and reconstruct the (msg . tag) representation for a deferred warning, so the other functions don't have to change. (uw_late_init): Register defr-warning as exception subtype of warning. * unwind.h (uw_muffle_deferrable_warning): Decl removed. * txr.1: Adjusted all documentation touching on the subject of the representation of deferrable warnings.
* keep/remove: reduce duplication, optimize.Kaz Kylheku2017-02-051-8/+8
| | | | | | | | | | | * lib.c (rem_impl): New static function. (remove_if): Rewritten similarly to rem_impl. (remq, remql, remqual, keepq, keepql, keepqual): Reduced to wrappers around rem_impl. (keep_if): Wrapper around remove_if with test negated. * lib.c (remq, remql, remqual, remove_if, keepq, keepql, keepqual, keep_if): Argument names adjusted.
* Rename proper_plist_to_alist function.Kaz Kylheku2017-01-241-1/+1
| | | | | | | * lib.c (proper_plist_to_alist): Renamed to plist_to_alist. * lib.h (proper_plist_to_alist): Declaration replaced. (plist_to_alist): Declared.
* New memp function for searching a plist.Kaz Kylheku2017-01-241-0/+1
| | | | | | | | | | * eval.c (eval_init): Register memp intrinsic. * lib.c (memp): New function. * lib.h (memp): Declared. * txr.1: Documented.
* 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.