summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* New special operator: progvKaz Kylheku2023-05-151-0/+62
| | | | | | | | | | | | | | | | | | | | | | Adding a progv operator, similar to the Common Lisp one. * eval.c (progv_s): New symbol variable. (op_progv): New static function. (do_expand): Recognize and traverse the progv form. (rt_progv): New static function: run-time support for compiled progv. (eval_init): Initialize progv_s, and register the the op_progv operator interpreting function. * stdlib/compilert (compiler compile): Handle progv operator ... (compiler comp-progv): ... via this new method. * tests/019/progv.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* doc: missing verb under makunbound.Kaz Kylheku2023-05-121-1/+1
| | | | | * txr.1: Add missing "removes" verb to first sentence of description of makunbound.
* Version 286.txr-286Kaz Kylheku2023-05-071-3/+3
| | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated.
* doc: remove "comprised of" in two places.Kaz Kylheku2023-05-061-7/+7
| | | | | | | * txr.1: an instance of "comprised of" disappears in a wording improvement under "Dot Position in Function Calls". Another instance under doloop is replaced by consisting of. I don't have anything against it, but it bothers some people.
* sort: support stable sorting via ssort and snsort.Kaz Kylheku2023-05-021-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For array-like objecgts, these objects use an array-based merge sort, using an auxiliary array equal in size to the original array. To provide the auxiliary array, a new kind of very simple vector-like object is introduced into the gc module: protected array. This looks like a raw dynamic C array of val type, returned as a val *. Under the hood, there is a heap object there, which makes the array traversable by the garbage collector. The whole point of this exercise is to make the new mergesort function safe even if the caller-supplied functions misbehave in such a way that the auxiliary array holds the only references to heap objects. * gc.c (struct prot_array): New struct, (prot_array_cls): New static variable. (gc_late_init): Register COBJ class, retaining in prot_array_cls. (prot_array_mark, prot_array_free): New static functions. (prot_array_ops): New static structure. (prot_array_alloc, prot_array_free): New functions. * gc.h (prot_array_alloc, prot_array_free): Declared. * lib.c (mergesort, ssort_vec): New static function. (snsort, ssort): New functions. * lib.h (snsort, ssort): Declared. * tests/010/sort.tl: Cover ssort. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* hash: new function, hash-props.Kaz Kylheku2023-05-011-0/+21
| | | | | | | | | | | | | | | | We don't have a function in the hash table module which can create a populated hash table in one step without requiring the caller to create auxiliary lists. This new function fills that gap, albeit with some limitations. * hash.c (hash_props): New function. (hash_init): Register hash-props intrinsic. * tests/010/hash.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* time: improved convenience in time functions.Kaz Kylheku2023-04-301-20/+50
| | | | | | | | | | | | | | | | * time.c (time_str_local, time_str_utc): New static functions. (time_fields_local, time_fields_utc, time_struct_local, time_struct_utc): Time argument becomes optional, defaulted to current time. (time_init): Use time_s symbol instead of interning twice. Register new time-str-local and time-str-utc intrinsics. Fix registration of functions that take optional args. * txr.1: New functions documented; optional arguments documented; existing documentation revised. * stdlib/doc-syms.tl: Updated.
* compiler: iterate on level 4-5 optimizations.Kaz Kylheku2023-04-071-1/+3
| | | | | | | | | | | | | * stdlib/optimize.tl (basic-blocks num-blocks): New method. * stdlib/compiler.tl (compiler optimize): At optimization level 6, instead of performing one extra pass of jump threading, dead-code elimintation and peephole optimizations, keep iterating on these until the number of basic blocks stays the same. * txr.1: Documented.
* compiler: optimization improvementsKaz Kylheku2023-04-071-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stdlib/optimize.tl (basic-blocks peephole-block): Drop the code argument, and operate on bl.insns, which is stored back. Perform the renames in the rename list after the peephole pass. (basic-blocks rename): New method. (basic-blocks do-peephole-block): Implementation of peephole-block, under a new name. The local function called rename is removed; calls to it go to the new rename method. (basic-blocks peephole): Simplify code around calls to peephole-block; we no longer have to pass bl.insns to it, capture the return value and store it back into bl.insns. * stdlib/compiler.tl (*opt-level*): Initial value changes from 6 to 7. (compiler optimize): At optimization level 6, we now do another jump threading pass, and peephole, like at levels 4 and 5. The peephole optimizations at level 5 make it possible to coalesce some basic blocks in some cases, and that opens up the possibility for more reductions. The previously level 6 optimizations are moved to level 7. * txr.1: Updated documentation of optimization levels, and default value of *opt-level*. * stdlib/doc-syms.tl: Updated.
* Version 285.txr-285Kaz Kylheku2023-03-281-3/+3
| | | | | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * time.c (struct tm_wrap): Fix for platforms without HAVE_TM_ZONE. We still need tm_wrap defined, just not the zone member. Out of the platforms I build releases for, Solaris is the only one like this.
* doc: compiler-opts typo.Kaz Kylheku2023-03-271-9/+9
| | | | | | | * txr.1: Fix compiler-opts, *compiler-opts* and with-compiler-opts to the correct "compile". * stdlib/doc-syms.tl: Updated.
* doc: range, range*: fix and maintain.Kaz Kylheku2023-03-271-22/+139
| | | | | | | | | | * txr.1: Updating the range and range* documentation, to describe the new features. Turns out, the documentation is horrible. It says that the functions work with integers, and doesn't mention that step can be a function, which was there from the beginning. I'm also changing wording which refers to the output being a lazy sequence to call it what it is: a lazy list.
* New function: arithp.Kaz Kylheku2023-03-261-0/+22
| | | | | | | | | | | | | | | | | | | * lib.h (arithp): Declared. (plus_s): Existing symbol declared. * arith.c (arithp): New function. * struct.h (special_slot): New enum member plus_m. * struct.c (special_sym): Register plus_s together as the [plus_m] entry of the array. * tests/016/arith.tl * tests/016/ud-arith.tl: Tests for arithp. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* doc: recommendations about unused warnings.Kaz Kylheku2023-03-251-0/+143
| | | | | | * txr.1: Adding a section under Lisp Compilation giving recommendations about how to suppress nuisance unused variable warnings.
* compiler/doc: document compiler-opts and enable unused warningKaz Kylheku2023-03-231-0/+151
| | | | | | | | | | * stdlib/compiler.tl (sys:env shadow-fun): Also diagnose if a global macro is shadowed. * txr.1: Documented compiler-opts structure, *compiler-opts* variable and with-compiler-opts macro. * stdlib/doc-syms.tl: Updated.
* doc: no such symbol as macroexpand-place-1Kaz Kylheku2023-03-231-2/+2
| | | | * txr.1: Replace macroexpand-place-1 with macroexpand-1-place.
* match: support @nil in predicates.Kaz Kylheku2023-03-231-2/+18
| | | | | | | | | | | | | | | | | For instance @(<= 10 @nil 20) is a pattern which matches a number between 10 and 20, without binding a variable. * stdlib/match.tl (compile-predicate-match): Looks like this code was already halfway expressing the intent that the avar could be nil, because arg-var takes the value of avar if that is non-nil, otherwise a gensym is substituted. What was missing was that the gensym that replaces nil must also be substituted into the predicate. * tests/011/patmatch.tl: New tests. * txr.1: Document that the variable embedded in a predicate may be null.
* New function: ignore, synonym of nilf.Kaz Kylheku2023-03-211-1/+22
| | | | | | | | | | | | | | | This will be an official mechanism for indicating deliberately unused variables. * eval.c (eval_init): Register ignore intrinsic, binding to the same function object as nilf. * stdlib/compiler.tl (%const-foldable-funs%): Mention ignore function, next to its nilf synonym. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* Allow t symbol in macro parameter lists.Kaz Kylheku2023-03-211-0/+20
| | | | | | | | | | | | | | | | | * eval.c (expand_params_rec, bind_macro_params): Handle t specially everywhere a parameter can occur. Expansion allows the syntax through without extending the environment with a t variable; binding walks over the structure without binding a variable. * stdlib/compiler.tl (expand-bind-mac-params): Likewise, handle occurrences of t, suppressing the generation of and assignment to variables, while ensuring that initializing expressions are evaluated. * tests/011/tree-bind.tl: New file. * txr.1: Documented.
* time: respect gmtoff in calculating numeric time.Kaz Kylheku2023-02-131-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have the following problem. On some platforms, the broken-down C time structure "struct tm" has a GMT offset field which gives the time zone of the specified time. In the Lisp structure, we call the corresponding slot gmtoff. This value should be taken into account when converting the broken-down time to a numeric time value. The underlying platform functions like mktime don't do this; they not only ignore the gmtoff, but in some cases clobber the field. The GNU C library version of the POSIX strptime function supports "%z" and "%Z" specifiers which populate the GMT offset. But then it gets wrongly ignored. Old/wrong behavior: 1> (time-parse-utc "%H:%M:%z" "00:00:+0900") 0 New behavior (on platforms with the GMT offset): 1> (time-parse-utc "%H:%M:%z" "00:00:+0900") 32400 * time.c (time_meth): If the Lisp time structure we are given specifies a non-nil gmtoff, then add its value to the returned result. (time_parse_local, time_parse_utc): If struct tm has a GMT offset, then we add its value to the time_t returned by mktime, timegm or timegm_hack. * txr.1: Updated.
* doc: * function not mentioned in heading.Kaz Kylheku2023-01-021-1/+1
| | | | | | | | | | | | * txr.1: The functions -, + and * are documented together, but the section heading only mentions + and -. This was introduced when these functions were documented for the first time in March 2012, in commit 6363875356bc050ef81d40553e573fc47aca2e28, and then went unnoticed for almost eleven years in spite of the heading undergoing relocation and reformatting. * stdlib/doc-syms.tl: Updated.
* doc: awk: mention res in clause descriptions.Kaz Kylheku2023-01-021-6/+14
| | | | | | * txr.1: In the description of the condition-action clause processing, mention the new res variable. Some additional improvements in neighboring text.
* Copyright year bump 2023.Kaz Kylheku2023-01-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, autoload.c, autoload.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.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, gzio.c, gzio.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lex.yy.c.shipped, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, psquare.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, socket.c, socket.h, stdlib/arith-each.tl, stdlib/asm.tl, stdlib/awk.tl, stdlib/build.tl, stdlib/cadr.tl, stdlib/compiler.tl, stdlib/constfun.tl, stdlib/conv.tl, stdlib/copy-file.tl, stdlib/debugger.tl, stdlib/defset.tl, stdlib/doloop.tl, stdlib/each-prod.tl, stdlib/error.tl, stdlib/except.tl, stdlib/ffi.tl, stdlib/getopts.tl, stdlib/getput.tl, stdlib/hash.tl, stdlib/ifa.tl, stdlib/keyparams.tl, stdlib/match.tl, stdlib/op.tl, stdlib/optimize.tl, stdlib/package.tl, stdlib/param.tl, stdlib/path-test.tl, stdlib/pic.tl, stdlib/place.tl, stdlib/pmac.tl, stdlib/quips.tl, stdlib/save-exe.tl, stdlib/socket.tl, stdlib/stream-wrap.tl, stdlib/struct.tl, stdlib/tagbody.tl, stdlib/termios.tl, stdlib/trace.tl, stdlib/txr-case.tl, stdlib/type.tl, stdlib/vm-param.tl, stdlib/with-resources.tl, stdlib/with-stream.tl, stdlib/yield.tl, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, time.c, time.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr, y.tab.c.shipped: Copyright year bumped to 2023.
* doc: fix date for 284 release.Kaz Kylheku2022-12-301-1/+1
| | | | * txr.1: Bump date to 2022-12-30.
* Version 284.txr-284Kaz Kylheku2022-12-301-2/+2
| | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* doc: spurious plural in JSON section.Kaz Kylheku2022-12-301-1/+1
| | | | * txr.1: "in supports of" -> "in support of".
* doc: grammar under awk.Kaz Kylheku2022-12-301-1/+1
| | | | | * txr.1: Description of rng column in table is missing the verb "shows".
* doc: trim-left: don't document string case as fixed regexKaz Kylheku2022-12-301-2/+2
| | | | | * txr.1: Though it's not wrong, let's describe the string case as a fixed match without mentioning regex.
* doc: clarify @(repeat) is @(collect :vars nil)Kaz Kylheku2022-12-301-1/+11
| | | | | | * txr.1: When @(repeat) is first mentioned near the top of the @(collect) documentation, say right away what exactly it means.
* awk: new feature, res variable.Kaz Kylheku2022-12-301-0/+44
| | | | | | | | | | | | | | | | The res variable captures the specific value of the condition expression, making it available to the action. * autoload.c (awk_set_entries): Intern the res symbol * stdlib/awk.tl (awk): Instead of generating the condition-action into a simple when, we use whenlet to also bind the res variable. * tests/015/awk-res.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* doc: consistency of condition-pattern term for awk.Kaz Kylheku2022-12-301-2/+2
| | | | | * txr.1: Fix instances of condition-pattern and condition-clauses to condition-action.
* doc: fix nonexistent macro name.Kaz Kylheku2022-12-301-1/+1
| | | | | | | * txr.1: *define-struct-prelude* should of course be define-struct-prelude. * stdlib/doc-syms.tl: Updated.
* doc: improve span-str, compl-span-str, break-strKaz Kylheku2022-12-101-0/+32
| | | | | * txr.1: document return value better for span-str and compl-span-str. Add examples for all three functions.
* doc: abc_function typo.Kaz Kylheku2022-12-101-1/+1
| | | | | * txr.1: In FFI-related example, a call to abc_function should just refer to function.
* expt: zero exponent yields 1.0.Kaz Kylheku2022-11-201-0/+3
| | | | | | | | * arith.c (expt): NUM-FLNUM, FLNUM-NUM and FLNUM-FLNUM cases ensure that if the expontent is zero, the return value is 1.0. Implementations of pow do this, but ISO C doesn't require it. * txr.1: Now documented.
* read-once: support globals properly.Kaz Kylheku2022-11-101-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | When a global variable v is wrapped with (read-once v), multiple accesses to the place still generate multiple accesses of the global through getv or getlx instructions. The reason is that the alet and slet macros optimize away a temporary bound to the value of a variable regardless of whether the variable is lexical. Let's fix that. * stdlib/place.tl (slet, alet): Replace the bindable test with lexical-var-p, in the given environment. A binding to a variable is only alias-like if the variable is lexical, otherwise we need a real temporary. * tests/012/struct.tl (get-current-menv): New macro. (menv): New global variable. Fix a number of tests which use expand, whose expansion has changed because the expressions refer to free variables. We introduce an environment parameter which binds all the variables, so that the optimized expansion is produced, as before. * txr.1: Updated documentation. slet gets examples.
* ftw: default flags to ftw-physKaz Kylheku2022-11-101-1/+21
| | | | | | | | | | | | | | | More often than not, you want the FTW_PHYS flag when calling the nftw function. Let's make that the default in TXR's wrapper. * ftw.c (ftw_wrap): Default to FTW_PHYS when flags argument not given, rather than zero, subject to compatibility option. (ftw_init): Don't check for FTW_PHYS with ifdef, since we relied on it being present. And anyway, any nftw implementation must have that. * txr.1: Documented.
* New feature: struct preludes.Kaz Kylheku2022-11-031-2/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | A struct prelude definition associates one or more future defstruct (by struct name) with clauses which are implicitly inserted into the defstruct. It is purely a macro-time construct, customizing the expansion behavior of defstruct. * stdlib/struct.tl (*struct-prelude, *struct-prelude-alists*): New special variables holding hash tables. (defstruct): Before processing slot-specs, augment it with the contents of the prelude definitions associated with this struct name. (define-struct-prelude): New macro. * autoload.c (struct_set_entries): define-struct-prelude is interned and triggers autoload of struct module. * tests/012/oop-prelude.tl: New file. * tests/012/oop-prelude.expected: Likewise. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* crypt: remove dubious validator.Kaz Kylheku2022-10-311-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | The validate_salt function was introduced in commit c3a0ceb2cea1a9d43f2baf5a2e63d0d712c8df19, February 2020. I cannot reproduce the internal crash in crypt which it alleges, and I neglected to mention the bad inputs in the commit or add tests. I'm not able to reproduce the alleged behavior in spite of trying all sorts of bad inputs; and looking at the crypt source in glibc, I don't see any obvious problem. And so, on this Halowe'en, we exorcise the ghost that has been haunting the crypt. * sysif.c (salt_char_p, validate_salt): Static functions removed. (crypt_wrap): Don't call validate_salt, and so cwsalt need not be tested for null. * tests/018/crypt.tl: New file. * txr.1: Mention that crypt_r is used if available, which avoids static storage.
* command line: set self-path for --compile.Kaz Kylheku2022-10-271-1/+27
| | | | | | | | | | | | | | | I noticed that when compiling a TXR Lisp program which refers to self-path using the --compile option, the compiler complained about self-path being unbound. * txr.c (self_path_s): New global variable. (do_compile_opt): Prior to running compile-update-file, bind self-path to the source path. (txr_main): Don't define local self_path_s, but initialize the global one. Replace redundant re-intering of self-path with a reference to self_path_s. * txr.1: self-path documentation updated.
* cat-str/join/join-with: allow nested sequencesKaz Kylheku2022-10-251-34/+30
| | | | | | | | | | | | | | | | | | | | | | | The measure/allocate/catenate functions which underlie the cat-str implementation are streamlined, simplifying the code. At the same time, they handle nested sequences of string/character items. * lib.c (struct cat_str): New member, seen_one. This flips from 0 to 1 after the first item has been seen in the cat_str_measure pass or cat_str_append pass. Each item other than the first is preceded by a separator. (cat_str_measure, cat_str_append): The more_p argument is dropped. We account for the separator with the help of the new seen_one flag, which allows us to easily recurse over items that are sequences. (cat_str_alloc): Reset the seen_one flag in preparation for the cat_str_append pass. (cat_str, vscat, scat2, scat3, join_with): Simplified. * tests/015/split.tl: New tests. * txr.1: Redocumented.
* defstruct: new :inherit clause.Kaz Kylheku2022-10-171-0/+24
| | | | | | | | | | | | | | | The :inherit clause allows custom struct clauses to inject inherited bases. * stdlib/struct.tl (defstruct): Recognize :inherit clause, adding symbol arguments to extra list of supers that get appended to the list coming from defstruct's seconda rgument. (define-struct-clause): Disallow :inherit clause name. * tests/012/oop-dsc.tl: New tests. * txr.1: Documented.
* doc: opip, flow: note about no-argument case.Kaz Kylheku2022-10-171-0/+20
| | | | | | | * txr.1: It's a developer surprise that (flow x) returns nil rather than x; which is due to the documented behavior of chain, when it has no arguments. Let's add cautionary notes.
* Version 283.txr-283Kaz Kylheku2022-10-161-3/+7
| | | | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. Also mention that separator commas in integer tokens are new in 283 and have a different interpretation in older versions. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* New function: macroexpand-struct-clause.Kaz Kylheku2022-10-131-0/+50
| | | | | | | | | | | * stdlib/struct.tl (macroexpand-struct-clause): New function. * autoload.c (struct_set_entries): Autoload struct module on macroexpand-struct-clause. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: macroexpand-match.Kaz Kylheku2022-10-131-0/+50
| | | | | | | | | | | * stdlib/match.tl (macroexpand-match): New function. * autoload.c (match_set_entries): Autoload match module on macroexpand-match. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: macroexpand-place.Kaz Kylheku2022-10-131-2/+71
| | | | | | | | | | | | | | | * stdlib/place.tl (sys:pl-expand): Function renamed to macroexpand-place; env parameter becomes optional. (macroexpand-1-place): New function. (place-form-p, call-update-expander, call-clobber-expander, call-delete-expander): Follow rename. * autoload.c (place_set_entries): Register symbols macroexpand-place and macroexpand-1-place for autoload. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: macroexpand-params.Kaz Kylheku2022-10-131-0/+66
| | | | | | | | | | | | | | | * stdlib/pmac.tl (macroexpand-params): New function, implemented using newly exposed sys:expand-param-macro. * autoload.c (pmac_set_entries): Trigger pmac.tl autload on macroexpand-params symbol. * eval.c (eval_init): Register existing expand_param_macro function as sys:expand-param-macro. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* doc: revise lambda examples.Kaz Kylheku2022-10-121-12/+49
| | | | | | | * txr.1: Fix formatting issue with .IP headings; add more examples showing (. arg) notation, use of : argument for requesting defaulting, and demonstration of presence-indicating variables.
* structs: optional init-exprs now useful in :delegateKaz Kylheku2022-10-111-8/+30
| | | | | | | | | | | | * stdlib/struct.tl (:delegate): Handle the two-element form of the optional parameter, which specifies the usual initializing expression for the default value. This is just passed through as-is to the generated method. Diagnose if the three-element form occurs. * tests/012/oop.tl: Some new tests. * txr.1: Documented.