summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* compiler: discard wrongheaded discards.Kaz Kylheku2023-04-081-55/+41
| | | | | | | | | | | | | | | | | | * stdlib/compiler.tl (compiler): Remove discards slot. (compile-in-toplevel, compile-with-fresh-tregs): Do not save and restore discards. (compiler maybe-mov): Method removed. It doesn't require the compiler object so it can just be a function. (maybe-mov): New function. (compiler alloc-discard-treg): Method removed. (compiler free-treg): No need to do anything with discards. (compiler maybe-alloc-treg): No need to check discards. (compiler (comp-setq, comp-if, comp-ift, comp-switch, comp-block, comp-catch, comp-let, comp-fbind, comp-lambda-impl, comp-or, comp-tree-case, comp-load-time-lit): Use maybe-mov function instead of method. (compiler comp-progn): Use alloc-treg rather than alloc-discard-treg, and use maybe-mov function.
* compiler: iterate on level 4-5 optimizations.Kaz Kylheku2023-04-073-10/+14
| | | | | | | | | | | | | * 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-074-75/+89
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* compiler: small local refactoring in optimizer.Kaz Kylheku2023-04-061-8/+4
| | | | | | | * stdlib/optimize.tl (basic-blocks peephole-block): Move local rename function into main labels block, so other optimizations will be able to use it. Remove an unused argument, and change the recursion to a mapcar, since that's what it's doing.
* conda/condlet: fix broken scope.Kaz Kylheku2023-04-061-8/+9
| | | | | | | | | | | Contrary to the documentation, the later clauses of a condlet have the earlier clause variables in scope. * stdlib/ifa.tl (sys:if-to-cond): Change to different, non-nesting expansion strategy. We lose the cond-oper parameter. (conda, condlet): Drop second parameter from calls to if-to-cond.
* unwind: fix backtrace-blocking issue.Kaz Kylheku2023-04-061-3/+4
| | | | | | | | * unwind.c (uw_rthrow): Only issue the with a "invalid re-entry of exception handling logic" and abort, if the exception being processed is an error. Warnings can occur during the execution of error diagnosis.
* quips: new car/cdr humor.Kaz Kylheku2023-04-041-0/+2
| | | | | * stdlib/quips.tl (%quips%): Two new entries punning on carcdr.
* hash: replace modulus with mask.Kaz Kylheku2023-04-031-26/+26
| | | | | | | | | | | | | | | | | In most places in the hash module, we reduce a hash code into the power-of-two sized table using h & (hash->modulus - 1). In some places we wastefully modulo operation h % hash->modulus. Why don't we replace the modulus with a mask so we can just do h & hash->mask. * hash.c (struct hash_ops): Replace modulus member with mask, which has a value one less. (hash_mark, hash_grow, do_make_hash, make_similar_hash, copy_hash, gethash_c, gethash_e, remhash, clearhash, hash_iter_next_impl, hash_iter_peek, do_weak_tables): Work with mask rather than modulus, preserving existing behavior.
* Version 285.txr-285Kaz Kylheku2023-03-287-841/+914
| | | | | | | | | | | | | | | | | * 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-272-10/+10
| | | | | | | * txr.1: Fix compiler-opts, *compiler-opts* and with-compiler-opts to the correct "compile". * stdlib/doc-syms.tl: Updated.
* range/range*: tests.Kaz Kylheku2023-03-271-0/+103
| | | | * tests/010/range.tl: New file.
* vim: syntax highlighting for ... decimal integers?Kaz Kylheku2023-03-271-0/+1
| | | | | | | | * genvim.txr (txr_num): Somehow, in spite of all the complexity and years of maintenance on this file, it generates syntax files that fail to recognize decimal integer tokens and color them like floating-point and other tokens like hex and octal. We now add (back?) the rule for that.
* vim: fix highlighting for uninterned symbolsKaz Kylheku2023-03-271-4/+3
| | | | | | * genvim.txr (tl_ident): Remove one rule, and make sure the other matches an optional : or #: (txr_braced_ident): Match optional : or #: prefix.
* 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.
* range, range*: use arithp.Kaz Kylheku2023-03-261-63/+45
| | | | | | | * eval.c (range, range_star); Instead of type switch use arith. This includes user-defined arithmetic objects. For that reason, in range_star, use equal instead of eql.
* New function: arithp.Kaz Kylheku2023-03-268-2/+55
| | | | | | | | | | | | | | | | | | | * 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.
* range/range*: connect with non-arithmetic rangesKaz Kylheku2023-03-261-7/+165
| | | | | | | | * eval.c (range_func_fstep, range_func_fstep_inf, range_func_iter, range_star_func_fstep, range_star_func_iter: New static functions. (range, range*): Analyze inputs and use the new functions for non-numeric ranges.
* 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-233-2/+158
| | | | | | | | | | * 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-233-5/+35
| | | | | | | | | | | | | | | | | 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.
* printer: print tree as #T(...) beyond max depth.Kaz Kylheku2023-03-231-0/+3
| | | | | | | * lib.c (obj_print_impl): For consistenfcy with other aggregates---lists, vectors and hashes---when the maximum depth has been exceeded we should likewise print binary search tree objects as #T(...).
* printer: [] shouldn't print as [. nil].Kaz Kylheku2023-03-232-3/+11
| | | | | | | | | | * lib.c (obj_print_impl): In the case when dwim has no args, and the logic short circuits to a closing brace, bypassing the loop, we should only use the dot notation if the terminating atom is other than nil. * tests/012/readprint.tl: Tests added.
* tests: squelch unused variable warnings.Kaz Kylheku2023-03-236-25/+29
| | | | | | | | | | | | | | | | | | * tests/011/patmatch.tl, * tests/019/pct-fun.tl: Disable unused warnings around file self-compilation. * tests/011/tree-bind.tl: Fix one unused variable instance using interned symbol. * tests/011/compile.tl: Disable unused warnings around all file compilation. * tests/012/lambda.tl: Use the parameter of one trivial lambda. * tests/common.tl: Disable unused warnings around compiled tests.
* lib: address remaining unused variable warnings.Kaz Kylheku2023-03-2226-129/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stdlib/arith-each.tl (sys-arith-each): Remove :form param. * stdlib/awk.tl (awk-state :fini): Suppress unused warning in dohash form by using an uninterned symbol for this variable. This is a useful technique worth documenting. (awk-expander): Remove unused varaible in a predicate pattern. (awk-code-move-check): Lose the unused awc and aws-sym. (awk-mac-let): Don't pass the unused parameters to awk-code-move-check. * stdlib/conv.tl (conv-expand): Remove unused gensym. * stdlib/debugger.tl (fcall-frame loc, fcall-frame print-trace, expand-frame print-trace): Mark unused parameters ignored. * stdlib/defset.tl (defset-expander-simple): Remove unused parameter. (defset): Drop argument from defset-expander-simple call, and also fix unused warning in tree-case form. * stdlib/doc-lookup.tl (detached-run): Remove unused variable from a pattern matching predicate. It's not in the rightmost position so we have to revers the comparison. I will enhance the pattern matcher to support @nil in a predicate. (toplevel): Ignore a parameter of the not-implemented version of the open-url function. * stdlib/doloop.tl (expand-dooloop): Replace unused variable in a tree binding pattern with the t symbol. * stdlib/each-prod.tl (expand-each-prod*): Remove unused let variable. * stdlib/except.tl (expand-handle): Put else variable in tree bind pattern to use. * stdlib/getopts.tl (opt-desc (basic-type-p, cumul-type-p)): Replace unused catch-all variable in tree bind pattern with t symbol. (opt-processor parse-opts): Remove unused args argument. The object holds the args, prepared at construction time. (getopts, option-base getopts): Don't pass args to parse-opts. (define-option-struct): Replace unused treee pattern variable with t. * stdlib/ifa.tl (if-to-cond): Put catch-all else variable to use. * stdlib/keyparams.tl (param-expander): Mark unused parameter ignored. Replace unused variables in tree-case with t. * stdlib/match.tl (compile-struct-match, compile-predicate-match, compile-require-match, compile-as-match, compile-with-match, compile-or-match, compile-and-match, compile-not-match, compile-hash-match, compile-scan-match, compile-exprs-match): Address unused variables in mac-param-bind and tree-bind patterns. (match-case): Likewise, and also remove unused let variables. (while-match-case, while-true-match-case): Remove unused :env parameter. (expand-lambda-match): Remove unused let variable. (defun-match): Remove unused variable in tree-bind. (define-param-expander): Mark menv parameter ignored. Unused variables in tree-bind. (defmatch): Replace lambda variable with a gensym. (loosen, pat-len): Remove unused parameter. (sme, end): Fix calls to loosen and pat-len. (non-triv-pat-p): Mark parameter ignored in the temporary version of this function. (expand-quasi-match): Address unused variables in patterns, and remove unused gensyms. * stdlib/op.tl (op-rec-p): Unused variable in tree-case. (op-alpha-rename): Remove f parameter. (op-ignerr): Mark catch handler parameter ignored. (op-expand): Remove argument from calls to op-alpha-rename. * stdlib/path.test (if-windows, if-native-windows): The compiler complains here about the unused variable due to constant folding. We use the use function to indicate that the variable is not ignored, but used. * stdlib/pic.tl (expand-pic-num): Remove unused let variable. (pic): Remove unused :env parameter. * stdlib/place.tl (macroexpand-1-place): Ignore unused env parameter. (pset): Ignore some tree-bind variables. Not replacing them with t because their names help code readability. Lots of tricky code in place.tl. (shift): Replace unused variable with t in tree-case. (vecref, chr-str, ref, sub): Deal with unused expander parameters. (gethash): Deal with unused place parameter. (dwim): Remove unused env parameter, and deal with unused place parameters. (get-fun-getter-setter): Unused variables in tree-bind. (read-once, define-modify-macro): Remove unused gensyms. (placelet-1): Mark ignored a parameter of an update expander lambda. * stdlib/pmac.tl (macroexpand-params): Fix unused catch-all in tree-case. * stdlib/struct.tl (prune-missing-inits): Mark tree-bind unused variable ignored. (defstruct): Unused tree-case variable. (qref): Unused tree-case catch-all variables. (rslot): Unused parameter removed. (:delegate): Unused tree-case variables. * stdlib/tagbody.tl (tagbody): Drop unused :env param. Mark ignored the threaded-2 let variable, which cannot be removed because its init-form performs a needed side effect. * stdlib/trace.tl (trace-leave): Remove unused param. (trace): Don't pass argument to unused param of trace-leave. (untrace): Use gensym in dohash to suppress unused variable warning. * stdlib/type.tl (typecase-expander): Unused variable in tree-case. * stdlib/with-resources.tl (with-resources): Likewise. * stdlib/yield.tl (hlet-expand): Remove two unused locals. * tests/012/lambda.tl: Fix test cases that break the tests due to unused variable warnings. * tests/016/arith.tl: Add test case for each-prod*. At first I thought a bug was found in it but it turned out that the init-forms variable that was removed was really superfluous.
* ffi: gc bugfix in ffi_type_struct.Kaz Kylheku2023-03-221-2/+2
| | | | | | | | | | | | | | | | I haven't reproduced a crash with this and --gc-debug doesn't do it, possibly due to the use of setcheck in the loop. But make_ffi_type_struct is doing something wrong: it's creating new compiled type objects in a loop and sticking them into the memb array, which is not visible to the garbage collector. * ffi.c (make_ffi_type_struct): We move the initialization of ffi->memb to above the loop, so that the object points to the array. The loop is already setting ft->nelem to the correct value i + 1 on each iteration of the loop, thereby revealing each newly populated entry to the garbage collector.
* ffi: gc bug in ffi_enum_type.Kaz Kylheku2023-03-221-0/+1
| | | | | | | | | This is reproducible using ./txr --gc-debug tests/017/ffi-misc.tl * ffi.c (ffi_enum_type_mark): We must mark the tft->eltype because enumerations use that member.
* compiler: dohash: source location propagationKaz Kylheku2023-03-221-8/+10
| | | | * stdlib/compiler.tl (expand-dohash): Add missing rlcp.
* compiler: forward source location for defun and defmacroKaz Kylheku2023-03-221-11/+15
| | | | | | | | | | | | | | * stdlib/compiler.tl (expand-defun): Sprinkling of rlcp to pass source location info to the generated lambda, and to the sys:define-method call. (expand-defmacro): bugfix here: in with-gensyms we shadowed the form parameter, and then passed that as both form arguments to expand-bind-mac-params. We rename the gensym to mform, and then for the error-form, we pass the original form, quoted as necessary and with source location info. Thus, now source location info flows from the original defmacro form to the generated let* which binds the destructured parameters.
* asm: unused variables.Kaz Kylheku2023-03-211-8/+37
| | | | | | | | | | | | | | | | * stdlib/asm.tl (oc-base backpatch, (backpatch-low-16 backpatch, backpatch-high16 backpatch, op-label (asm, dis), op-noop dis, op-frame dis, op-end dis, op-movrs dis, op-movsr dis, op-movrr dis, op-jmp (backpatch,dis), op-if (backpatch, dis), op-ifq backpatch, op-block backpatch, op-retsr dis, op-retrs dis, op-retrr dis, op-catch (backpatch, dis), op-handle dis, op-getv dis, op-setv dis, op-close (backpatch, dis), op-getlx dis, op-setlx dis): Suppress warnings about unused variables using ignore and other approaches. (assembler dis-listing): The unused stream parameter here is a real bug: it was intended to be the output destination, rather than standard output being hard-coded.
* lib: switch from use function to ignore functionKaz Kylheku2023-03-213-20/+19
| | | | | | | | | | | * stdlib/compiler.tl (compiler (comp-atom, comp-dwim), safe-const-reduce, igno-notfound): Use ignore rather than use for marking unused variable. * stdlib/copy-file.tl (copy-files, copy-path-rec, remove-path-rec, chmod-rec, chown-rec): Likewise. * stdlib/optimize.tl (basic-block print): Likewise.
* compiler: recognize ignore and use functionsKaz Kylheku2023-03-211-2/+9
| | | | | | | | | | | | | | | We want the ignore function to go away; but if variables are mentioned, to suppress unused warnings on them. * stdlib/compiler.tl (%functional-funs%): Remove nilf from list since we are handling it specially. (compiler comp-fun-form): Recognize (ignore ...) and (nilf ...) forms, transforming them into (progn .... nil). In the case of ignore, walk the arguments: if any look like variables, mark them used. Also, add the use function to the pattern which handles identity, since it is a synonym.
* New function: ignore, synonym of nilf.Kaz Kylheku2023-03-214-5/+32
| | | | | | | | | | | | | | | 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.
* copy-file: fix unused warnings.Kaz Kylheku2023-03-211-13/+32
| | | | | | * stdlib/copy-file.tl (copy-files, copy-path-rec, remove-path-rec, chmod-rec, chown-rec): Fix instances of unused parameters.
* ignerr: fix unused warningKaz Kylheku2023-03-213-2/+11
| | | | | | | | | | | | | | | | | | | | The ignerr intrinsic macro generates code that has an unused variable. We fix it by turning it into a gensym, since unused warnings aren't generated for gensyms. * eval.c (unused_arg_s): New static variable. (me_ignerr): Use the value of unused_arg_s instead of error_s, for the argument of the catch clause. (eval_init): gc-protect unused_arg_s. (eval_late_init): New function in which we initialized unused_arg_s. The gensym function cannot be used during eval_init. * eval.h (eval_late_init): Declared. * lib.c (init): Call eval_late_init after some other late initializations.
* compiler: unused warnings in optimizer.Kaz Kylheku2023-03-211-62/+62
| | | | | | | | | | | | | | | | | | * stdlib/optimizer.tl (basic-block print): Suppress warning for pretty-p parameter using the use function. (basic-blocks (local-liveness, calc-liveness, thread-jumps-block, peephole-block, late-peephole, fill-treg-compacting-map), (basic-block apply-treg-compacting-map), dedup-labels): Fix unused variables in pattern, mostly by replacing them by @nil. (basic-blocks check-bypass-empty): Method moved, turned into (basic-block check-bypass-empty), losing the unused basic-blocks parameter. (basic-blocks elim-next-jump): Likewise moved into basic-block class. (basic-blocks elim-dead-code): Calls to check-bypass-empty and elim-next-jump adjusted.
* compiler: bug: unmatchable pattern in optimizer.Kaz Kylheku2023-03-211-1/+1
| | | | | | | | | | | This was uncovered by unused variable warnings. * stdlib/optimize.tl (basic-blocks peephole-block): The pattern trying to detect wasteful register moves is incorrect; the reg1 term is intended to be the @reg1 variable. It is matched literally and so will not match because the symbol reg1 does not literally occur in the VM code.
* compiler: fix remaining unused variable warningsKaz Kylheku2023-03-211-66/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | Now that we have the t convention in macro parameters, we can use it to suppress many cases of unused variables in the compiler. * stdlib/compiler.tl (compiler (comp-setq, comp-lisp1-setq, comp-setqf, comp-cond, comp-ift, comp-switch, comp-unwind-protect, comp-return, comp-handler-bind, comp-catch, eliminate-frame, comp-lambda-impl, comp-fun, comp-or, comp-prog1, comp-arith-form, comp-arith-neg-form, comp-fun-form, comp-apply-call, comp-for, comp-tree-bind, comp-mac-param-bind, comp-mac-env-param-bind, comp-tree-case, comp-lisp1-value, comp-dwim, comp-prof, comp-load-time-lit), expand-quasi-mods, expand-dohash, expand-each, expand-defvar, expand-defun, expand-defmacro, expand-defsymacro, lambda-apply-transform, usr:compile): Fix unused variable warnings mostly by using the t mechanism in tree-case or mac-param-bind. In some cases, (use var) is used where it would be detrimental to diagnostic quality to replace identifiers in the pattern with t. A few unused "else" variables were renamed and used. (safe-const-reduce, ign-notfound): Fix unused exception clause unused parameters using (use param).
* time: crash: glibc overwrites time zone with literalKaz Kylheku2023-03-211-13/+21
| | | | | | | | | | | | | | | | | | | | | | | | A crash occurs in the make_time_impl function whereby the mktime or timegm function invoked via the pmktime(&local) call overwrites the TIME_ZONE field with a string literal. We dynamically allocated that string and expect to free it in the time_fields_cleanup function. The solution is to wrap the struct tm structure with a container which separately tracks that pointer and frees that copy of it. * time.c (struct tm_wrap): New struct type. (time_fields_to_tm): Take a pointer to struct tm_wrap instead of struct_tm, and stash the timezone string in the wrapper. (time_fields_cleanup): Take a a pointer to struct tm_wrap and free the stashed pointer in the container, which is immune to TM_ZONE being altered. (time_struct_to_tm): Take pointer to tm_wrap because this calls time_fields_to_tm. (make_time_impl, time_string_meth, time_parse_meth): Use struct tm_wrap instead of struct tm.
* Allow t symbol in macro parameter lists.Kaz Kylheku2023-03-214-28/+80
| | | | | | | | | | | | | | | | | * 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.
* compiler: fix unused variable situationsKaz Kylheku2023-03-201-34/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We fix numerous unused variable situations uncovered by the new diagnostic. Most of those occurring inside tree-bind or mac-param-bind forms remain unfixed. These are caused by the idiom of binding a dummy variable as a placeholder in the structure. I am instead going to introduce a mechanism into tree-bind/mac-param-bind for indicating an ignored piece of structure. * stdlib/compiler.tl (compiler (comp-if, eliminate-frame, comp-lambda-impl, comp-typep, comp-fun-form, expand-and, reduce-or, compiler-emit-warnings, usr:compile with-compile-opts): Eliminate unused variables in structural pattern matches in various ways: eliminating predicate argument variables, replacing place holder variables by @nil, or just using the variables when possible. (compiler compile-in-toplevel): Remove unused saved-nlev variable. (compiler comp-atom): Use (use oreg) form to suppress unused parameter warning. (compiler comp-return-form): Eliminate unused binfo variable. The lookup-block method is called for the side effect of marking the block used, so we keep that call. (compiler comp-let): Unused variable specials is gone. (compiler comp-or): Unused variable lastfrag is gone, as is the assignment to it. There is a reason assignment isn't use! (compiler comp-inline-lambda): Get rid of the two variables called dummy by folding the associated calculation into an adjacent initform using progn and prog1. (comp-tree-case): Remove unused ncases, lerrtest and lnext variables. (safe-const-eval): Remove unused reduced-form variable, and simplify code, eliminating another local.
* compiler: recognize t as synonym for :warn.Kaz Kylheku2023-03-201-1/+1
| | | | | * stdlib/compiler.tl (opt-controlled-diag): If a the compiler option's value is t, treat it as :warn.
* compiler: source-loc propagation in tree-bind, lambdaKaz Kylheku2023-03-202-89/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Unused variables in tree-bind forms are not generating diagnostics with source location info. We are missing some rlcp calls. * stdlib/compiler.tl (compiler comp-catch): The generated lambda here ends up transformed to a let by the lambda-apply-transfom function. We must propagate source info to it, otherwise unused catch clause parameters get diagnosed without it. (compiler (comp-for, comp-mac-param-bind, comp-mac-env-param-bind, comp-tree-case): Confer source location info onto the err-form argument of expand-bind-mac-params. (expand-bind-mac-params): Pass source location info from err-form onto the generated let* form. Thus, diagnostics related to variables in that let* get reported against that form's location. (lambda-apply-transform): Pass source location info from the lambda expression to the generated let. * stdlib/except.tl (usr:catch): Pass source loc info from each clause source code to the transformed clause. The transformed clause will turn into a lambda which will turn into a let in comp-catch, and then into a let in lambda-apply-transform.
* compiler: recognize use function as constant-foldableKaz Kylheku2023-03-201-1/+1
| | | | | * stdlib/constfun.tl (%const-foldable-funs%): use is a synonym of identity, which is listed; now use is also listed.
* compiler: implement unused warningKaz Kylheku2023-03-202-8/+21
| | | | | | | | | | | | | | | | * autoload.c (compiler_set_entries): Register slot symbol "unused". * stdlib/compiler.tl (compile-opts): New slot, unused. (%warning-syms%): List unused symbol. (env lookup-var): Support optional mark-used parameter, just like lookup-fun. (env unused-check): New method. (compiler comp-var): Pass t to mark-used parameter of lookup-var to register the use. (compiler (comp-let, comp-var)): Call unused-check method after sub-compilations are done to dump diagnostics about unused variables.
* compiler: compiler options mechanism.Kaz Kylheku2023-03-202-4/+71
| | | | | | | | | | | | | | | | | | | | | | | Introducing a compiler options system, so we can control diagnostics and such. We begin with three options for diagnosing shadowing. * autoload.c (compiler_set_entries): Register a structure name compiler-opts, a with-compile-opts function name, *compile-opts* variable name, and slots shadow-fun, shadow-var and shadow-cross. * stdlib/compiler.tl (compile-opts): New struct. (%warning-syms%): New macro. (*compile-opts*): New special variable. (when-opt, with-compile-opts): New macros. (opt-controlled-diag): New function. (env extend-var): Call extend-var* method instead of repeating code. (env extend-var*): Implement shadow-var and shadow-cross diagnostic options. (env extend-fun): Implement shadow-fun and shadow-cross diagnostic options.
* configure: note about ccname in --help text.Kaz Kylheku2023-03-191-1/+3
| | | | | * configure: add a note that the ccname variable is not used if the cc variable does not interpolate $(ccname).
* ffi: c++: several C-style casts have snuck inKaz Kylheku2023-02-281-4/+4
| | | | | | * ffi.c (make_ffi_type_struct, make_ffi_type_union, ffi_type_compile): Use convert macro instead of C cast notation.
* txr: bugfix, allow lazy lists in multi match.Kaz Kylheku2023-02-271-0/+1
| | | | | | | | | * match.c (do_match_line): Handle LCONS the same way as CONS. When a variable occurs whose value is a list of strings, that may be a lazy list. I ran into a problem using @(data x) to capture a list of strings, and then matching that with @x; the error being "unsupported object in spec", caused by the list's LCONS type not handled in this switch.
* New audio-related quip.Kaz Kylheku2023-02-211-0/+1
| | | | | | * stdlib/quips.tl (%quips%): New entry: what if we apply the concept of channel separation to audiophiles who hate each other's guts?