summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* matcher: support @(some pat) operator.Kaz Kylheku2021-01-151-4/+8
| | | | | | | | | | | | | | | | This is the existential quantifier to accompany @(all). * share/txr/stdlib/match.tl (compile-loop-match): Check for the some symbol in a few places and adjust the output. We don't need a local binding of the patter's variables, only the temps. The values go directly to the outer binding of the variables which are not shadowed now. We also don't need the nreverse logic to set the outer variables: var-exprs is nil at the outer level. The polarity of the loop termination test is reversed: we quit the loop on the first match, as is the polarity of the return value: if the loop is aborted early t is returned instead of nil. (compile-match): Wire in the some operator.
* matcher: some renaming in all match.Kaz Kylheku2021-01-151-10/+12
| | | | | | | | | | | | This is in anticipation of using the same function to compile other patterns that involve iteration. * share/txr/stdlib/match.tl (compile-all-match): Function renamed to compile-loop-match. The successful match and loop termination variables are renamed to different symbols. Also, test for the usr:all* symbol explicitly rather than all for making the test consp. (compile-match): Follow function rename.
* matcher: use flag to eliminate block.Kaz Kylheku2021-01-151-3/+4
| | | | | | | * share/txr/stdlib/match.tl (compile-all-match): We use a flag to break out of the loop instead of (return). The loop's block is thereby later eliminated by the compiler. For this we re-purpose the same all-match-p-var symbol.
* matcher: fix semantics of empty @(all ...) match.Kaz Kylheku2021-01-152-2/+10
| | | | | | | | | | | | * lisplib.c (match_set_entries): Ensure usr:all* is interned. * share/txr/stdlib/match.tl (compile-all-match): When the operator is the existing all, we must listp as a guard, not consp, because an empty list must match vacuously by virtue of not containing any counterexample to the pattern. For situations when a vacuous empty match is not desired, we support the all* alternative operator, which uses consp. (compile-match): Wire in the all* operator.
* matcher: support @(all pat) operator.Kaz Kylheku2021-01-151-0/+37
| | | | | * share/txr/stdlib/match.tl (compile-all-match): New function. (compile-match): Hook it in.
* matcher: allow omitted variabel in predicatesKaz Kylheku2021-01-151-1/+1
| | | | | | | | | | For instance @(oddp) instead of @(oddp x) to require an element to satisfy oddp without capturing it to a variable. * share/txr/stdlib/match.tl (compile-predicate-match): Make the symbolic argument optional, defaulting to nil. A nil symbol is already treated as pseudo-variable which consumes an item without binding to a variable.
* matcher: improve error reporting.Kaz Kylheku2021-01-151-12/+16
| | | | | | | | | | | | | | So quick and dirty; you have to love special variables. * share/txr/stdlib/match.tl (*match-form*): New special variable. (compile-var-match, compile-predicate-match, compile-let-match): Use compile-error instead of error, passing the value of *match-form* as the context. (compile-match): Ditto, and eliminate unreachable case from cond form. (when-match): Capture form directly into special variable using :form *match-form*.
* matcher: factor out vars into common base.Kaz Kylheku2021-01-141-18/+18
| | | | | | | | | | | | | | | | | | | * share/txr/stdlib/match.tl (match-vars): New struct. Holds vars and expressions, and provides the method to zipper them up into the assignments. (match-guard, compiled-match): Inherit from match vars. match-guard loses temps and temp-exprs. It now has vars and var-exprs from the base and those are used instead. (compiled-match get-temps): Follow temps vars rename. (compiled-match wrap-guards): Use assignments method inherited from base instead of assignments function. (assignments): Function removed. (compile-struct-match, compile-vec-match, compile-cons-structure): Follow vars temps rename in match-guard struct. (when-mach): Use assignments method of compiled-match instead of assignments function.
* new: structural pattern matching.Kaz Kylheku2021-01-142-0/+202
| | | | | | | | * lisplib.c (match_instantiate, match_set_entries): New static functions. (lisplib_init): Register autoload using new statics. * share/txr/stdlib/match.tl: New file.
* build: support linker flags/libs separation.Kaz Kylheku2021-01-142-20/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our build system lumps all linker options together. The correct way is that linker flags are separated info flags and libs. Also, we respond to the LDFLAGS variable but ignore LDLIBS which is incorrect. Other issues are fixed. All that is fixed here. * Makefile (TXR_CFLAGS): Interpolate $(CFLAGS) last, so that options coming from CFLAGS can override previous options. (TXR_LDFLAGS): Interpolate $(LDFLAGS) last; same reason. (TXR_LDLIBS): New variable. (LINK_PROG): Put $(TXR_LDFLAGS) with the options, before the -o, and put $(TXR_LDLIBS) at the end. * configure (conf_ldlibs, platform_ldlibs): New variables. (usage text): Document platform-ldlibs and adjust documentation of platform-ldflags. (gen_config_make): Generate PLATFORM_LDLIBS and CONF_LDLIBS now needed by Makefile. (mainline): Adjusts various recipes to use conf_ldlibs instead of conf_ldflags, or in some cases both. In the case of libffi where we use pkg-config, we use the special pgk-config options to separately extract the flags and libs. We use EXTRA_LDLIBS instead of EXTRA_LDFLAGS in some conftest invocations, as necessary.
* Copyright year bump 2021.Kaz Kylheku2021-01-14128-130/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * METALICENSE: 2020 copyrights bumped to 2021. Added note about SHA-256 routines from Colin Percival. * LICENSE, LICENSE-CYG, Makefile, alloca.h, args.c, args.h, arith.c, arith.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, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lex.yy.c.shipped, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.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/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/copy-file.tl, share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/each-prod.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/param.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/quips.tl, share/txr/stdlib/save-exe.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/vm-param.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, 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 2021.
* vm: derive duplicated constants from Lisp origin.Kaz Kylheku2021-01-113-4/+14
| | | | | | | | | | | | | | | | | | | | | Some constnats in vm.c are hand-duplicates of ones in vm-param.tl. Let's put them in vmop.h instead, where they can be generated by the genvmop.txr script. The two new constants are anticipated for some upcoming VM work. * genvmop.txr: Generate the existing VM_LEV_BITS, VM_LEV_MASK, VM_SM_LEV_BITS and VM_SM_LEV_MASK from the Lisp constants. Also, let's add two new ones. * vm.c (VM_LEV_BITS, VM_LEV_MASK, VM_SM_LEV_BITS, VM_SM_LEV_MASK): Preprocessor symbols removed. * vmop.h (VM_LEV_BITS, VM_LEV_MASK, VM_SM_LEV_BITS, VM_SM_LEV_MASK): Preprocessor symbols generated here with identical values. (VM_MAX_LEV, VM_MAX_V_LEV): New constants.
* quips: new entriesKaz Kylheku2021-01-071-0/+2
| | | | | * share/txr/stdlib/quips.tl (sys:%quips%): East Van cross and reference to urban myth regarding Sports Illustrated cover.
* doc: stray functions in heading and syntaxKaz Kylheku2021-01-051-3/+1
| | | | | | | | * txr.1: The documentation section for makunbound also erroneously lists the fmakunbound and mmakunbound functions in the heading and syntax block. They are not documented there, but in their own section which follows and has its own heading, so these references to them must be removed.
* quips: improve one about side-effects.Kaz Kylheku2021-01-051-1/+1
| | | | * share/txr/stdlib/quips.tl (sys:%quips%): Updated.
* configure: tweak test for inline.Kaz Kylheku2021-01-041-3/+2
| | | | | | | | | | | | | | | | | | | | It seems that the Brew people are running into a problem. The configure test is detecting that "inline" can be used for declaring inline functions, but then some functions are not inlined, requiring an external definition. On GNU/Linuxes, we detect "static inline", so this doesn't reproduce. This is likely triggered by the recent change to compile as C99 (unless configuring in maintainer mode). * configure: Let's revise the set of possible definitions of INLINE that we try. Firstly, we only try "inline" if we are compiling as C++. If that fails, all the other forms of inline we try include "static". Let's not mess with anything involving "extern". Like a bare "inline", it might work in the test program but cause some sort of failure.
* progn, prog1, prog2: now also functions.Kaz Kylheku2021-01-013-8/+50
| | | | | | | | | | | | * eval.c (progn_fun, prog1_fun, prog2_fun): New static functions. (eval_init): Wire progn, prog1 and prog2 function bindings to new functions. * txr.1: Documented. * checkman.txr (check-func): Recognize Macro/function and Operators/functions heading.
* New macro: prog2Kaz Kylheku2021-01-012-5/+59
| | | | | | | | | | | | * eval.c (prog2_s): New symbol variable. (me_prog2): New macro expander function. (eval_init): Initialize prog2_s variable with interned symbol. Register prog2 macro expander. * txr.1: Maintain the documentation for progn and prog1, improving the wording and adding a dialect note . Document prog2.
* eval: use symbol vars for registering if, and or.Kaz Kylheku2021-01-011-3/+3
| | | | | * eval.c (eval_init): Use if_s, or_s, and_s instead of wastefully calling intern.
* gc: streamlining finalization-related code.Kaz Kylheku2021-01-011-4/+4
| | | | | | | | | | | | | | * gc.c (prepare_finals): Do not move unreachable objects with finalizers into generation 0 here. (call_finalizers_impl): Don't test the object for being in generation 0; that may not be true since we don't ensure that in prepare_finals now. Instead check he reachable flag of he finalization entry; that tells us that we are dealing with an object that had been found unreachable. When we re-introduce it into freshobj, we set its generation to zero. Also, don't bother with this freshobj logic if the full_gc flag has been set. That now includes not bothering to set object generations to zero.
* gc: do finalizers completely on one phase.Kaz Kylheku2021-01-012-37/+58
| | | | | | | | | | | | | | | | | | | | | | * gc.c (call_finalizers_impl): Iterate over the finalizer registrations until no more finalizers are identified, performing additional rounds, as necessary. Thus if finalizers register more finalizers that are eligible for processing according to the criteria of he current phase, those are done in the current phase. (gc_finalize): We must now carefully set the reachable flag to 1 for a new finalization entry. This was always the right thing to do and is logically correct: if an object is being passed to finalize, it is necessarily reachable. Leaving the 0 initialization would do bad things now, as follows. If any object whatsoever has a finalizer registered against it during GC-driven finalization, its finalizer will be called. This is bad if the object isn't garbage. Secondly, the object may be moved into generation 0, and put into the freshobj list. This is extremely bad if the object is reachable by generation 1 objects, which is now a wrong-way reference. * txr.1: Updated.
* Version 246txr-246Kaz Kylheku2020-12-315-266/+293
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* gc: add finalization count to objects.Kaz Kylheku2020-12-314-20/+28
| | | | | | | | | | | | | | | | | | | | | | | | With the finalization count, we don't have to scan the freshobj array for duplicates when calling finalizers. However, the limited range of the counter limits how many times we can register a finalizer against an object. * gc.c (make_obj): Reset the new fincount field to zero for a newly minted object. (call_finalizers_impl): Decrement the fincount for each object. Only run the freshobj-related logic when the count hits zero. (gc_finalize): Bump the fincount of a registered object. If the counter overflows, throw an exception. * lib.h (obj_common): Add new field fincount for the finalization count. * tree.c (tr_rebuild): Fix up dummy object initializer to accommodate the new member. * txr.1: Document that there is a limit on the number of times an object can be registered for finalization.
* gc: fix unnecessary full gc request in finalization.Kaz Kylheku2020-12-311-2/+2
| | | | | | | | | * gc.c (call_finalizers_impl): Objects are only added to freshobj if they are in the zero generation. We should skip that entire block of code if the object isn't in that generation. Not only is it wasteful to execute that code for the mature generation, but the logic falsely sets the full_gc flag whenever processing a non-gen-0 object!
* awk: tests for fconv.Kaz Kylheku2020-12-312-0/+21
| | | | | * tests/015/awk-fconv.tl, * tests/015/awk-fconv.expected: New files.
* doc: improve awk fconv documenation.Kaz Kylheku2020-12-311-0/+16
| | | | | | * txr.1: List the no-conversion - operator among the shortcuts, so it is easier to discover. Add a note that that fconv is potentially applicable to non-string fields.
* gc: bug: finalization logic causing gc assertKaz Kylheku2020-12-311-7/+17
| | | | | | | | | | | | | | | | | | | | | This problem was introduced on Feb 18, 2019 in commit 3931df5cba3d826511503ad1c0a5b84c1363765e. Explicit finalization of objects outside of GC can trigger an assertion in a later GC pass. * gc.c (call_finalizers_impl): We simply must not have duplicate entries in fresh_obj; this causes problems for sweep_one. Under Valgrind debugging, sweep_one protects the memory of processed entries, so a duplicate visit triggers bad accesses. A more serious issue is that this function can be called outside of gc, explicitly, since it is available as an API function. So that is to say, non-garbage objects can have their finalizers called ouside of GC. If this function is called explicitly, outside of GC, it can end up doing something stupid, like adding a generation 1 object into the freshobj array, triggering an assert. We address this by not doing any of that processing if GC is not taking place.
* doc: note for awk macro fconv.Kaz Kylheku2020-12-291-0/+11
| | | | * txr.1: Add usage note to the fconv macro.
* awk: bugfix: load compiled verison of conv.tl.Kaz Kylheku2020-12-291-1/+1
| | | | | * share/txr/stdlib/awk.tl: Load "conv", not "conv.tl", so that if there is a .tlo present, it is loaded instead.
* awk: bugfix: fconv symbols not in usr package.Kaz Kylheku2020-12-292-13/+16
| | | | | | | * share/txr/stdlib/conv.tl (sys:conv-let): Use usr: package prefix on the conversion symbols i, o, x, b. They are being interned in the system package, which breaks the awk fconv macro.
* quips: use random-state argument in shuffle call.Kaz Kylheku2020-12-291-2/+1
| | | | | * share/txr/stdlib/quips.tl (quip): Don't bind *random-state*; pass an argument to shuffle.
* shuffle/nshuffle: take optional random state argument.Kaz Kylheku2020-12-294-11/+13
| | | | | | | | | | | | | * eval.c (eval_init): Register shuffle and nshuffle as two-argument functions with optional argument. * lib.c (nshuffle): Take random-state argument, defaulting to value of random_state special variable. (shuffle): Take random-state argument, pass down to nshuffle. * lib.h (shuffle, nshuffle): Declarations updated. * txr.1: Updated.
* shuffle/nshuffle: eliminate wasteful vector copy.Kaz Kylheku2020-12-291-1/+1
| | | | | | * lib.c (nshuffle): When shuffling the vector that was converted from the list, use nshuffle rather shuffle, because it's a temporary, non-shared object we can mutate.
* quips: new one.Kaz Kylheku2020-12-281-0/+1
| | | | * share/txr/stdlib/quips.tl (sys:%quips%); New entry.
* quip: function cycles through all quips.Kaz Kylheku2020-12-281-1/+6
| | | | | | * share/txr/stdlib/quips.tl (sys:%shuffled-quips%): New variable. (quip): Pop quips from the new variable. When the list is empty, populate it by shuffling the quips.
* doc: correction in dialect notes for symbol-macroKaz Kylheku2020-12-271-3/+5
| | | | | * doc: Common Lisp has a function like symbol-macro function; it is called macro-function.
* Version 245txr-245Kaz Kylheku2020-10-104-9/+36
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. Fixed repeated word in documentation under env-hash. * share/txr/stdlib/ver.tl: Bumped from incorrect 243 value to 245.
* chmod: disable some chmod tests on Cygwin.Kaz Kylheku2020-12-241-21/+26
| | | | | | | * tests/018/chmod.tl: Certain chmod test cases no longer work on Cygwin. The issue is the chmod system call. It produces completely nonsensical results in some cases. We disable these test cases on Cygwin.
* linenoise: fix: int used instead of wchar_t.Kaz Kylheku2020-12-241-2/+2
| | | | | * linenoise.c (scan_match_rev, scan_match_fwd): The value of s[i] must be captured in a wchar_t, not int.
* android: fix socket module, failing tests.Kaz Kylheku2020-12-235-15/+18
| | | | | | | | | | | | | * socket.c: Add missing #include <netinet/in.h>. * tests/017/glob-carray.tl, tests/017/glob-zarray.tl: Use same definition for struct glob as Cygwin. Both are of BSD origin. * tests/017/realpath.tl: Do not test on Android. * tests/common.tl (os-symbol): Detect Android and return :android. (libc): Handle :android.
* configure: don't disable PIE on Android.Kaz Kylheku2020-12-231-25/+29
| | | | | | | * configure: Move how-to-disable-PIE check below plaform detections, where we know whether we have Android or not. On Android, we can't disable PIE; non-PIE executables are not supported. Let's cross our fingers things work.
* build: Android support.Kaz Kylheku2020-12-232-0/+22
| | | | | | | | | | * Makefile (conftest.android): New helper target for testing for Android toolchain, via presence of __ANDROID__ preprocessor symbol, similarly to how we detect Darwin. * configure: New test for Android. This is mutually exclusive agains Darwin. On Android, we add some necessary feature selection macros to the compiler command line.
* configure: rename darwin variable.Kaz Kylheku2020-12-231-3/+3
| | | | * configure (need_darwin_c_source): Renamed to darwin_target.
* configure: get rid of -Wold-style-declarationKaz Kylheku2020-12-231-1/+1
| | | | | | | | * configure (diag_flags): Remove the -Wold-style-declaration option. It is not useful, unlike -Wold-style-definition; it warns agains some unspecified old style usages, like storage class specifiers not being first. Moreover, clang 10 does not recognize this option and complains.
* configure: relax to C99 for regular users.Kaz Kylheku2020-12-221-2/+9
| | | | | | | | | | | The code will continue to stick to C90, but requesting C90 compatibility from GCC may break for downstream users in some environments that don't support C90 in their header files. * configure (lang_flags): Remove -ansi option from here. (usage): Help text for maintainer mode updated. (mainline): Add -std=c++98 to the front of lang_flags if compiling as C++, -std=c90 in maintainer mode, else -std=c99.
* configure: C++ fix for recently added C flags.Kaz Kylheku2020-12-221-0/+1
| | | | | | | * configure: When we detect we are using C++, we filter out certain C-only compiler options. TO that list, we must add a pattern that gets rid of the recently added -Wold-style-definitions and -Wold-style-declarations.
* configure: C++ fix for type size detection case.Kaz Kylheku2020-12-221-4/+4
| | | | | | | | | | * configure: The new logic for detecting type sizes introduced in October, replacing the old nm-based trick, doesn't work with C++. An anonymous structure is being used to define an object with linkage: we fix that by giving the structure a tag name which be. C++ also doesn't like a one-character string literal like "\n" being used to initialize a char [1] array, so we make it [2].
* shipped lexer: fix misleading indentation.Kaz Kylheku2020-12-221-5/+5
| | | | | * lex.yy.c.shippped (YY_DECL): Fix some bad indentation, most likely caused by using a mixture of tabs and spaces.
* int-flo: bugfix on 64 bitKaz Kylheku2020-12-221-2/+9
| | | | | | | | | | | | | | | * arith.c (int_flo): On 64 bit, we incorrectly handle the positive floating-point values which correspond to (expt 2 63) and (expt 2 64). This is because in the range check which detects whether a double value lands into the cnum or ucnum range, the 64 bit INT_PTR_MAX and UINT_PTR_MAX have no exact equivalent in the double type and are being converted to double values which are greater. That then causes the range check to incorrectly include double values that are actually out of range for the conversion to the cnum or ucnum type, causing bogus values. The quickest fix would be to use < comparison for a half-open range, but that sacrifices two double values on 32 bit, unnecessarily sending them to the text-based conversion code. So instead, let's subtract margins from the range constants on 64 bit.
* build: add more warnings against ancient C.Kaz Kylheku2020-12-131-1/+3
| | | | | | * configure (diag_flags): Add warning options agains defining an old style C function, and against obsolecent features in declarations.