summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* doc: listp and proper-list-p are list only.Kaz Kylheku2019-06-161-0/+6
| | | | * txr.1: Clarify that list-like sequences are not lists.
* doc: improvements in sub + replace variants.Kaz Kylheku2019-06-161-43/+34
| | | | | | | | | | | | * txr.1: The wording is improved in the description of sub-list, replace-list and all the other type specific specializations of sub and replace. We avoid starting the descriptions with "This function", and vague wording such as "is like the sub function". Superfluous, obvious text like "for a description of the semantics, see the sub function" is removed. Also we avoid saying that the sub-list and replace-list functions operate strictly on lists, since they in fact operate on anything that supports list operations.
* doc: carray-pun copy-paste issue.Kaz Kylheku2019-06-151-1/+1
| | | | | * txr.1: Fix syntax section for carray-pun wrongly showing carray-sub function name.
* buffers: expose sub-buf and replace-buf.Kaz Kylheku2019-06-151-0/+59
| | | | | | | * buf.c (buf_init): Intrinsics sub-buf and replace-buf registered. * txr.1: Documented.
* compile-file: translate --lisp option in hash bang.Kaz Kylheku2019-06-141-1/+5
| | | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Edit the hash-bang line to replace the --lisp option with --compiled. This supports the situation when a TXR Lisp hash bang script that is unsuffixed is compiled to an unsuffixed compiled script.
* cat-str, split-str: sep can be character.Kaz Kylheku2019-06-141-5/+7
| | | | | | | * lib.c (cat_str, split_str_keep): Support single character separator. * txr.1: Documented.
* select: maintenance.Kaz Kylheku2019-06-141-8/+17
| | | | | | | | | * lib.c (sel): Function converted to seq_info and iterators. Negative indices handled in list case. Self-name corrected to select; the C function is called sel just to avoid clashing with POSIX select. * txr.1: Documentation updated.
* replace-list: negatives in index-list follow convention.Kaz Kylheku2019-06-141-5/+13
| | | | | | | | | | The index-list replacement isn't following the convention that negative index values reference from the end of the target sequence. Let's fix that. * lib.c (replace_list): Likewise. * txr.1: Documentation updated.
* sub-vec: optimize no-op case.Kaz Kylheku2019-06-121-2/+1
| | | | | | | | | | * lib.c (sub_vec): If range covers entire vector, just return it. * txr.1: Clarify that the output of sub may share structure with the input regardless of type, not only when the input is a list. This should have been updated when the optimizatin was done in sub-str.
* doc: no such thing as varray.Kaz Kylheku2019-06-121-6/+6
| | | | | | * txr.1: carray is contrasted with the FFI type varray; but there is no such type. varray is a name used internally in the implementation; it means "variable-length zarray".
* doc: clarifications under zarrayKaz Kylheku2019-06-121-6/+17
| | | | | * txr.1: Clarify how the null element in the C array is generated for the dimensioned and undimensioned zarray.
* ffi: adjust in semantics of variable zarray.Kaz Kylheku2019-06-121-6/+2
| | | | | | | | | | | | | | | | | The replace function now returns a list if a nil object's is replaced with a range, rather than just returning the original item sequence. This breaks the variable array in operation, causing it to produce a list. We fix this sproblem, and also the nonsense semantics of the operation also; the operation should replace the original sequence, with the array, similarly to how null terminated strings work. * ffi.c (ffi_varray_null_term_in): If the original Lisp object isn't nil, then assume it's a sequence and replace it with the items gathered in the vector. Otherwise, replace it with the vector. * txr.1: Adjust documentation.
* New function: hash-peek.Kaz Kylheku2019-06-111-8/+25
| | | | | | | | | * hash.c (hash_peek): New function. (hash_init): hash-peek intrinsic registered. * hash.h (hash_peek): Declared. * txr.1: Documented.
* Version 217.txr-217Kaz Kylheku2019-06-101-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* Adding errno constants.Kaz Kylheku2019-06-091-0/+19
| | | | | | | | | | | | | | | | | | | | * sysif.c (sysif_init): registering variables e2big, eacces, eaddrinuse, eaddrnotavail, eafnosupport, eagain, ealready, ebadf, ebadmsg, ebusy, ecanceled, echild, econnaborted, econnrefused, econnreset, edeadlk, edestaddrreq, edom, edquot, eexist, efault, efbig, ehostunreach, eidrm, eilseq, einprogress, eintr, einval, eio, eisconn, eisdir, eloop, emfile, emlink, emsgsize, emultihop, enametoolong, enetdown, enetreset, enetunreach, enfile, enobufs, enodata, enodev, enoent, enoexec, enolck, enolink, enomem, enomsg, enoprotoopt, enospc, enosr, enostr, enosys, enotconn, enotdir, enotempty, enotrecoverable, enotsock, enotsup, enotty, enxio, eopnotsupp, eoverflow, eownerdead, eperm, epipe, eproto, eprotonosupport, eprototype, erange, erofs, espipe, esrch, estale, etime, etimedout, etxtbsy ewouldblock and exdev. * txr.1: Documented.
* Adding fcntl interface.Kaz Kylheku2019-06-091-0/+168
| | | | | | | | | | | | | | | | | | | * configure: changing HAVE_FCNTL_H to HAVE_FCNTL. * sysif.c (flock_s, type_s, whence_s, start_s, len_s, pid_s): New symbol variables. (flock_pack, flock_unpack, fcntl_wrap): New static functions. (sysif_init): Initialize new symbol variables. Create flock struct type. Register new intrinsic variables: o-accmode, o-rdonly, o-wronly, o-rdwr, o-creat, o-noctty, o-trunc, o-append, o-nonblock, o-sync, o-async, o-directory, o-nofollow, o-cloexec, o-direct, o-noatime, o-path, f-dupfd, f-dupfd-cloexec, f-getfd, f-setfd, fd-cloexec, f-getfl, f-setfl, f-getlk, f-setlk, f-setlkw, f-rdlck, f-wrlck, f-unlck, seek-set, seek-cur and seek-end. Register fcntl intrinsic function. * txr.1: Documented.
* place macros: adjustment to expansion strategy.Kaz Kylheku2019-06-051-17/+29
| | | | | | | | | | * share/txr/stdlib/place.tl (sys:pl-expand): At each expansion round, repeatedly expand the form as a place macro until that can no longer be done and only then try macroexpand-1, instead of just trying one place macro expansion. * txr.1: Updated and revised description of expansion under define-place-macro.
* posix: add close function.Kaz Kylheku2019-05-301-0/+22
| | | | | | | * sysif.c (close_wrap): New static function. (sysif_init): close intrinsic registered. * txr.1: Documented.
* doc: missing word under mask.Kaz Kylheku2019-05-291-1/+1
| | | | * txr.1: add missing "or" to make "bitwise or".
* doc: typo under ldiff.Kaz Kylheku2019-05-291-1/+1
| | | | * txr.1: Misplaced comma nudged left.
* doc: formatting of sident charsKaz Kylheku2019-05-291-3/+3
| | | | * txr: use .verb block instead of .mono block.
* path-private-to-me-p: bugfix: not including superuser.Kaz Kylheku2019-05-291-14/+22
| | | | | | | | | | | | * share/txr/stdlib/path-test.tl (path-private-to-me, path-strictly-private-to-me): These functions were neglecting to trust the root user, as documented. If the file is owned by root, we treat it as if it were owned by the caller. Furthermore, if we have to process the group membership, we allow the group to contain the superuser's name. * txr.1: Documentation improved, and the treatment of groups documented.
* Version 216.txr-216Kaz Kylheku2019-05-201-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* doc: missing deindent under Function FiltersKaz Kylheku2019-05-201-1/+1
| | | | * txr.1: .PP added.
* compile-file: input path harmonized with load.Kaz Kylheku2019-05-201-15/+81
| | | | | | | | | | | | | | * share/txr/stdlib/compiler.tl (open-compile-streams): The input file is now determined in a manner similar to the load function. If the path is relative and there is a *load-path* binding, then it is now considered relative to *load-path*. It is considered suffixed only if ending in .tl or .txr. If unsuffixed, then it is first tried with the .tl suffix. (usr:compile-file): Bind *load-path* to the actual path used for loading the file, rather than the input path. * txr.1: Documented.
* load: always bind *load-path* to actual path.Kaz Kylheku2019-05-201-14/+25
| | | | | | | | | | | * eval.c (load): Bind *load-path* to the real path that was used to open the file, not to the tentative path to which the .tl suffix was added, subject to compatibility option. * txr.1: Documentation for load revised for better wording and to document the above change. Fixed *load-path* being wrongly called a macro, and also load being called a macro. Compat note added.
* oop: derived hook.Kaz Kylheku2019-05-151-11/+67
| | | | | | | | | | | * struct.c (derived_s): New symbol variable. (struct_init): Initialize derived_s symbol. (make_struct_type): Check for derived method in parent, and invoke. * struct.h (derived_s): Declared. * txr.1: Documented.
* oop: new new* and lnew* macros.Kaz Kylheku2019-05-151-0/+27
| | | | | | | | | | | | * lisplib.c (struct_set_entries): Add autoload entries for new* and lnew* symbols. * share/txr/stdlib/struct.tl (sys:new-type, sys:new-expander): New functions. (new, lnew): Macros now implemented using sys:new-expander. (new*, lnew*): New macros. * txr.1: Documented.
* oop: new function: struct-type-name.Kaz Kylheku2019-05-151-0/+14
| | | | | | | | | * struct.c (struct_init): Register struct-type-name intrinsic. (struct_type_name): New function. * struct.h (struct_type_name): Declared. * txr.1: Documented.
* loading: try unsuffixed files directly last.Kaz Kylheku2019-05-011-62/+104
| | | | | | | | | | | | | | | | | | | | | | | | | In this patch we change the strategy for resolving unsuffixed paths in load and @(load). In load, an unsuffixed name is tried with a .tlo suffix, then .tl and only if those don't resolve to a file it is tried as-is. The previous order is as-is, .tlo, .tl. Similarly in @(load), but unsuffixed paths are tried as .txr, then .tlo, then .tl. The motivation for this is to avoid probing the filesystem multiple times the optimized case that we care about: loading .tlo files from Lisp. * parser.c (open_txr_file): Rearrange the probing strategy. Also recognize .txr_profile as a suffix, treating it like .tl. This is so that we don't probe for .txr_profile.tlo and .txr_profile.tl before finding the profile. (load_rcfile): Take advantage of the new path-not-found exception. We avoid wastefully checking with path-exists-p to avoid calling open_txr_file. We just let open_txr_file throw an exception if the file doesn't exist, and then distinguish the non-existence case in the handler. * txr.1: Updated @(load) and load documentation.
* lib: more nuanced file access errors.Kaz Kylheku2019-05-011-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Several new more specific exception types are derived from file-error and used. Error handlers can distinguish unexpected non-existence, unexpected existence and permission errors from each other and other errors. * lib.c (path_not_found_s, path_exists_s, path_permission_s): New symbol variables. (obj_init): New variables initialized. * lib.h (path_not_found_s, path_exists_s, path_permission_s): Declared. * parser.c (open_txr_file): Use new errno_to_file_error function to convert errno to exception symbol. * socket.c (open_sockfd): Likewise. * stream.c (open_directory, open_file, open_fileno, open_command, open_process, run, remove_path, rename_path): Likewise, and process-error is used in open_process and run instead of file-error for problems related to creating the process. * sysif.c (errno_to_file_error): New function. (mkdir_wrap, ensure_dir, chdir_wrap, getcwd_wrap, mknod_wrap, chmod_wrap, symlink_wrap, link_wrap, readlink_wrap, stat_impl, umask_wrap, ): Use errno_to_file_error to convert errno to exception symbol. (exec_wrap): Use process-error instead of file-error. * sysif.c (errno_to_file_error): Declared. * unwind.c (uw_init): Register path-not-found, path-exists and path-permission as subtypes of file-error. * txr.1: Documented.
* New function: window-mapdo.Kaz Kylheku2019-04-211-1/+9
| | | | | | | | | | | | | | | | * lib.c (enum wmap_op): New enum type. (window_map_list): Use enum wmap_op for last argument instead of Boolean flag. If the argument is WMAP_MAPDO, do not accumulate. (window_map_vec, window_map, window_mapped): Adjust to new enum argument. (window_mapdo): New function. * lib.h (window_mapdo): Declared. * eval.c (eval_init): window-mapdo intrinsic registered. * txr.1: Documented.
* doc: document --backtraceKaz Kylheku2019-04-201-0/+12
| | | | | * txr.1: Document --backtrace and also that it is implied by --debug.
* New function: allocate-struct.Kaz Kylheku2019-04-191-0/+24
| | | | | | | | * struct.c (struct_init): allocate-struct intrinsic registered. (allocate_struct): New static function. * txr.1: Documented.
* Support max length and depth for object printing.Kaz Kylheku2019-04-181-0/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * hash.c (hash_print_op): Implement max length. * lib.c (lazy_str_put, out_lazy_str): Take struct strm_base * parameter and implement max length. (out_quasi_str_sym): Don't use obj_print_impl for symbol's name string; just put_string. The use of obj_print_impl causes symbols appearing as variables in quasiliterals to be truncated when max length is imposed. (out_quasi_str): Implement max length. (obj_print_impl): Implement max length and depth. Note that there is now always a non-null ctx pointer. (obj_print): Always set up context pointer for obj_print_impl. Context now has pointer to low-level stream structure, where we can access max_length and max_depth. It also carries the recursion depth. * lib.h (lazy_str_put): Declaration updated. * stream.c (strm_base_init): Add initializers for max_length and max_depth. (put_string): Pass stream structure to lazy_str_put. (set_max_length, set_max_depth): New functions. (stream_init): set-max-length and set-max-depth intrinsics registered. * stream.h (struct strm_ctx): New members depth and strm. (struct strm_base): New members max_length and max_depth. (set_max_length, set_max_depth): Declared. * txr.1: Documented.
* doc: wrongly formatted with-resources example.Kaz Kylheku2019-04-171-7/+8
| | | | | | * txr.1: example of with-resources should use .verb not .mono. This must be because it previously used .cblk without indentation.
* streams: force-off indent mode.Kaz Kylheku2019-04-161-18/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fourth indent mode indent-foff (force off) is introduced. * buf.c (buf_print): Turn on data mode indentation if the current mode is not indent-foff, rather than when it is indent-off. * lib.c (obj_print_impl): The unconditional set_indent_mode calls are replaced with test_neq_set_indent_mode so we only set the mode if it is not forced off. * stream.c (formatv): For the ! directive, turn on data mode identation is not indent-foff, rather than when it is indent-off. (put_string, put_char, width_check): Recognize ident-foff as indentation off. (test_neq_set_indent_mode): New function. (stream_init): Register test-neq-set-indent-mode function and indent-foff variable. * stream.h (indent_mode): New enum constant, indent_foff. (test_neq_set_indent_mode): Declared. * struct.c (struct_inst_print): Turn on data mode indentation if the current mode is not indent-foff, rather than when it is indent-off. * txr.1: Documented.
* New catch** macro.Kaz Kylheku2019-04-101-1/+29
| | | | | | | | | * lisplib.c (except_set_entries): Autoload for catch** symbol. * share/txr/stdlib/except.tl (catch**): New macro. * txr.1: Document catch** macro, and the desc slot of the catch-frame struct.
* debug support: crude debugger removed.Kaz Kylheku2019-04-091-328/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug.c (debug_depth, debug_quit_s): Variables removed. (step_mode, next_depth, breakpoints, last_command, cols): Static variables removed. (debug_check): C99 inline instantiation removed. (help, show_bindings): Static functions removed. (debug): Function removed. (debug_set_state): Now takes one int argument, returns int. It's anticipated that the new debug system will have a simple on-off switch; there won't be a debug_depth hack. (debug_restore_state): Function removed. (debug_init): Emptied. * debug.h (debug_depth, debug_state_t): Declarations removed. (debug_enter, debug_leave, debug_return): Macros removed. (debug_check): Inline function removed. (debug_set_state): Declaration updated. (debug_restore_state): Declaration removed. (debug_frame, debug_end): Macros removed. * eval.c (do_eval, me_interp_macro): Debugging support scrubbed. * lisplib.c (lisplib_try_load): Adapt to debug_set_state interface change. * match.c (h_fun, do_match_line, v_fun, match_files, match_fun): Debugging support scrubbed. * parser.y (parse_once): Adapt to debug_set_state interface change. * protsym.c: Regenerated. * signal.h (debug_depth): Declaration removed. (EJ_DBG_MEMB, EJ_DBG_SAVE, EJ_DBG_REST): Macros removed. (EJ_OPT_MEMB, EJ_OPT_SAVE, EJ_OPT_REST): Reduced to unconditionally empty definitions for future use. * unwind.c (uw_push_debug): Function removed. * unwind.h (uw_frtype_t): UW_DBG enum member removed. (struct uw_debug): struct declaration removed. (union uw_frame): db member removed. (uw_push_debug): Declaration removed. * txr.1: Debugger doc removed.
* doc: update debug session.Kaz Kylheku2019-04-071-59/+147
| | | | | * txr.1: Repeated debug session with new version of the navytime.txr script, and the latest TXR.
* doc: fix overlong lines.Kaz Kylheku2019-04-061-19/+43
| | | | | | * txr.1: Reformat lines in .verb blocks that are wider than 79 columns for the sake of reading the manual with man on an 80 column terminal.
* doc: split .cblk into .verb and .monoKaz Kylheku2019-04-061-2086/+2096
| | | | | | | | | | | | | | | * txr.1 (.cblk, .cble): Macros renamed to .mono and .onom respectively. (.verb, .brev): New macros. These are like .cblk and .cble but instead of just switching the font, they switch in and out of non-formatting mode also with .nf/.fi. Everywhere in the document, .cblk/.cble used for just font changes are replaced with .mono/.onom, and those instances used for preformatted code blocks are replaced with .verb/.brev. * checkman.txr (check-cblk): Removed. (check-mono, check-verb): New pattern functions.
* New function: cptr-size-hint.Kaz Kylheku2019-04-061-0/+20
| | | | | | | | | | * eval.c (eval_init): Register cptr-size-hint intrinsic. * lib.c (cptr_size_hint): New function. * lib.h (cptr_size_hint): Declared. * txr.1: Documented.
* doc: forgotten cptr functions.Kaz Kylheku2019-04-061-0/+29
| | | | * txr.1: Document cptrp and cptr-type.
* Version 215.txr-215Kaz Kylheku2019-03-301-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* u-d-arithmetic: proper treatment of ceil & round.Kaz Kylheku2019-03-301-35/+4
| | | | | | | | | | | | | | | * arith.c (r_ceil_s, r_round_s): New symbol variables. (ceildiv, roundiv): Route binary cases involving struts directly to binary methods so the object is responsible for the complete implementation. (arith_init): Initialize r_ceil_s and r_round_s. * tests/016/ud-arith.tl (numbase): Binary methods added for ceil and round. Test cases added. * txr.1: Descriptions for binary ceil and round methods added; Notes about non-existence of binary methods removed from unary ceil and round removed.
* Tests for user-defined arithmetic and fixes.Kaz Kylheku2019-03-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | * tests/016/ud-arith.expected b/tests/016/ud-arith.tl: New file. * tests/016/ud-arith.expected b/tests/016/ud-arith.expected: New file. * arith.c (divi): Bugfix: wrong argument tested for being a COBJ. (logtrunc): Fix incorrect method call: calling r-logtrunc-s for the object-in-left-position case. (sign_extend): Fix semantics not following documentation: dispatch method with original arguments. (divv): When there is just one argument, take advantage of the hitherto unused unary case of divi rather than giving it both arguments. The object dispatch is in that unary case, so we need it now. (arith_init): Fix wrong name of r_lognot_s symbol. * txr.1: Fix atan2 being documented as atan. Fix misspelling of r-lognot as lognot-r.
* New feature: user-defined math.Kaz Kylheku2019-03-301-0/+509
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the library now accepts struct objects as arguments, relying on them to implement methods. * arith.c (minus_s, inv_minus_s, neg_s, abs_s, signum_s, mul_s, div_s, recip_s, inv_div_s, trunc1_s, trunc_s, r_trunc_s, mod_s, r_mod_s, zerop_s, plusp_s, minusp_s, evenp_s, oddp_s, gt_s, lt_s, ge_s, le_s, numeq_s, expt_s, r_expt_s, exptmod_s, isqrt_s, square_s, floor_s, floor1_s, r_floor_s, ceil_s, ceil1_s, round_s, round1_s, sin_s, cos_s, tan_s, asin_s, acos_s, atan_s, atan2_s, r_atan2_s, log_s, log2_s, log10_s, exp_s, sqrt_s, logand_s, logior_s, logxor_s, lognot1_s, lognot_s, r_lognot_s, logtrunc_s, r_logtrunc_s, sign_extend_s, ash_s, bit_s, width_s, logcount_s): New symbol variables. (not_struct_error, method_error, do_unary_method, do_binary_method, do_ternary_method): New static functions. (plus, minus, neg, abso, signum, mul, trunc1, trunc, mod, floordiv, round1, roundiv, divi, zerop, plusp, minusp, evenp, oddp, gt, lt, ge, le, numeq, expt, exptmod, isqrt, square, floorf, ceili, since, cosi, tang, asine, atang, atang2, loga, logten, logtwo, expo, sqroot, logand, logior, logxor, comp_trunc, lognot, sign_extend, ash, bit, logcount, width, bits, unary_num, unary_arith): Support struct arguments. (plusv, minusv, mulv, divv, sumv, prodv, gtv, ltv, gev, lev, numeqv, exptv, logandv, logiorv): Use symbol for self instead of string lit. (arith_init): Initialize new symbol variables. Replace existing intern calls in function registrations with references to some of these symbol variables. * txr.1: Documented.
* doc: umax is misdocumented.Kaz Kylheku2019-03-261-6/+60
| | | | | | | * txr.1: umask returns the current value, not the value t. The argument is optional, for just returning the current value, which is done via a destructive trick that we should document. Mention all the permission constants also.
* Version 214.txr-214Kaz Kylheku2019-03-221-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.