summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Man page checker update.Kaz Kylheku2017-01-121-3/+19
| | | | | | | | | | | | | | * checkman.txr (check-func): Bugfix: neglect to scan .synb sections for two types of headings. Include accessors, methods and structs in the check. (check-cblk): Use @(last) rather than @(until) so closing .cble is consumed. Otherwise the new check for dangling .cble will report false positives. (check-spurious): New pattern function to detect dangling .syne and .cble. (main loop): Include a stand-alone .synb check for the sake of special sections like Update expander. Include check-spurious.
* doc: bad cblk and synb.Kaz Kylheku2017-01-121-9/+8
| | | | | * txr.1: Fix numerous instances of bad .cble/.cblk usage and replace one .synb/.syne with .cblk/.cble.
* doc: spurious blank line.Kaz Kylheku2017-01-121-1/+0
|
* doc: use markup in struct syntax.Kaz Kylheku2017-01-121-6/+6
| | | | | * txr.1: Use .mets in syntax block for frame, catch-frame anf handle-frame, as well as time.
* doc: bad headings.Kaz Kylheku2017-01-121-2/+2
| | | | | * txr.1: Fixed spurious comma in Methods car ... heading and no and @ in Accessors caar ...
* doc: blank line after .desc.Kaz Kylheku2017-01-121-1/+0
| | | | * txr.1: Fixed under symbol-value.
* doc: bad .IKaz Kylheku2017-01-121-1/+1
| | | | * txr.1: .I with run-on comma after quote becomes .IR.
* doc: shorten param macro memoization example.Kaz Kylheku2017-01-121-6/+1
| | | | * txr.1: Replace silly loop with idiomatic code.
* doc: formatting issue in param macros example.Kaz Kylheku2017-01-121-1/+1
| | | | * txr.1: Fix .cble that should be .cblk.
* Version 165.txr-165Kaz Kylheku2017-01-106-779/+803
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Eliminate rejection of empty clauses.Kaz Kylheku2017-01-081-87/+27
| | | | | | * parser.y (grammar): Remove all checks which raise a syntax error if a clause is empty. These reject some correct situations, getting in the programmer's way.
* Allow last var to be omitted in whilet.Kaz Kylheku2017-01-062-3/+30
| | | | | | | * eval.c (me_whilet): insert gensym if last var is missing. Warn if init-form looks like a variable. * txr.1: Documented by copy and paste from iflet.
* Missing space in hash printed rep.Kaz Kylheku2017-01-061-0/+1
| | | | | * hash.c (hash_print_op): For hash tables that have both weak keys and weak values, print a space between the keywords.
* New Lisp feature: param list expander.Kaz Kylheku2017-01-044-6/+302
| | | | | | | | | | | | | | | | | | | | | * eval.c (pm_table): New static variable. (expand_param_macro): New static function. (expand_params): Expand parameter list macros via expand_param_macro. (eval_init): gc-protect pm_table and initialize it. Register *param-macro* variable. * lisplib.v (pmac_set_entries, pmac_instantiate): New static functions. (lisplib_init): Register autoloading of pmac.tl via new functions. * share/txr/stdlib/pmac.tl: New file. * txr.1: Notes under defun, lambds, flet/labels and defmacro about the existence of parameter macros which add to the syntax. New Parameter List Macros section. Documented *param-macro* and define-param-expander.
* Version 164.txr-164Kaz Kylheku2017-01-016-142/+175
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* bugfix: sys:setq bindable check must be warning.Kaz Kylheku2017-01-011-1/+7
| | | | | | | | | | | | | | | The problem is that during the expansion of something like (do inc @1), the place expansion will generate a (sys:setq @1 ...) form which undergoes expansion before the processing which converts @1 to a gensym. But now that throws an error during the expansion of the sys:setq form that @1 isn't a bindable symbol. Since warnings are suppressed during this expansion phase, we can make it a warning. * eval.c (not_bindable_warning): New static function. (do_expand): For the assignment special forms, throw a warning if the target isn't a bindable symbol, not an error.
* Bugfix: repeated expansion of catch unstable.Kaz Kylheku2016-12-314-18/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | It turns out we have a silly problem: catch is a special operator, which undergoes a macro-like expansion which alters its syntax, but uses the same operator symbol. We turn catch into a macro which expands to a sys:catch operator. * eval.c (sys_catch_s): New symbol variable. (expand_catch): Function now expands sys:catch forms without altering any syntax. (do_expand): Check for sys:catch rather than catch. Call expand_catch differently: it takes the form now instead of just the arguments, so it can return the original form if no expansion takes place. (eval_init): Initialize sys_catch_s variable. Change registration of op_catch to sys:catch symbol. * lisplib.c (except_set_entries): Add catch to the list of autoload symbols for except.tl. * share/txr/stdlib/except.tl (catch): New macro for transforming catch to sys:catch. * txr.1: Reclassify catch operator as a macro.
* Check for non-symbols in catch clauses.Kaz Kylheku2016-12-311-0/+2
| | | | | * eval.c (expand_catch_clause): Check added that clause sym must be a symbol.
* Bugfix: quasilit var read-print consistency.Kaz Kylheku2016-12-311-2/+9
| | | | | | | | | | | | | | The problem is that objects like `@{foo:bar} @{*xyz*}` are printing as `@foo:bar @*xyz*` without the required braces. This changes the meaning, as in @foo:bar which is @foo followed by the text :bar, or creates a syntax error, as in @*xyz*. * lib.c (out_quasi_str): When printing a var, first convert it to a string form by printing to a string stream. Then if the string form consists of anything other than letters, digits and underscores, mark it as needing braces, in addition to the existing conditions.
* Check assignment special forms at expansion time.Kaz Kylheku2016-12-291-35/+29
| | | | | | | | | | | | | | * eval.c (lispq_setq_s, setqf_s): New symbol variables. (op_defvarl, op_defsymacro, op_defmacro, op_setq, op_lisp1_setq, op_setq): Drop bindability checks. In the case of defmacro, this is already taken care of so the check is redundant. (do_expand): Add bindable check to defvar_s and cousins. In the function form fallback case, check for the various assignment operators and check their argument count and bindability of destination symbol. (eval_init): Initialize new symbol variables; register corresponding special operators using variables.
* Reintroduce lambda checks and macro param bugfix.Kaz Kylheku2016-12-291-37/+67
| | | | | | | | | | | | | | | | | | | | | | Fix nested macro parameters not being expanded properly in all cases. Diagnose uses of :env, :form and :whole in function parameter lits. * eval.c (expand_opt_params_rec, expand_params_rec): New parametr, macro_style_p, indicating destructuring macro parameter list is to be expanded. Restructure the cases in expand_opt_params_rec to fix a bug: only recursively treating a nested parameter A only when A stands alone, or without a default form as (A), failing to do so when it is (A B ...). Diagnose :env, :whole or :form inside a function parameter list. Do not process recursive parameter lists for functions; diagnose nesting as bad syntax. (expand_params): Add macro_style_p parameter. (expand_macrolet, expand_tree_cases): Pass t as argument to new parameter of expand_params. (do_expand): Pass t or nil as argument to new parameter of expand params, based on whether expanding a macro or function parameter list.
* Bugfix: optarg presence indicators may be specials.Kaz Kylheku2016-12-291-0/+7
| | | | | | | | | | | This fixes the incorrect treatment of the x-p parameter in (lambda (: (x form x-p))) when x-p is a special variable. It is being lexically bound. * eval.c (expand_opt_params_rec): When processing a (var initform) pair, check for (var initform sym). Error out if sym is not bindable. Check if it is special and if so, push it into the list of specials.
* Hoist binding and arg checking to expansion time.Kaz Kylheku2016-12-291-171/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Checking for uses of non-bindable symbols in variable binding and argument lists is moved to expansion time. Also checked at expansion time are macro lambda list conventions. :env and others must have a bindable parameter, and the optional arg colon cannot occur twice. * eval.c (bind_args): Remove run-time checks that are now done at expansion time. (not_bindable_error): New function. (expand_opt_params_rec, expand_params_rec): Take form argument for reporting errors. Implement more detailed checking against non-bindable symbols, and against :env, :form and :whole having missing or unsuitable arguments. (expand_params): Take form argument for error reporting, and pass to expand_params_rec. (bind_macro_params, bindings_helper): Remove run-time checks that are now done at expansion time. (check_lambda_list): Function removed, because expand_params now does the bulk of this check. We have a regression here in that we lose the check against :env and others occurring in a function parameter list; this has to be worked into expand_params. (op_defvarl, op_defsymacro, op_defmacro, op_setq, op_lisp1_setq, op_setqf): Replace repeated code with call to not_bindable_error. However, these should be replaced by expansion-time checks anyway, and eventually will be. (expand_macrolet): Pass form to expand_params. (expand_tree_cases): Take form argument for error reporting. Pass to expand_params. (expand_tree_case): Pass form to expand_tree_cases. (me_def_variable, me_mlet): Replace repeated code with call to not_bindable_error. (expand_vars): Do bindable symbol check here, so it doesn't have to be done at the run time in bindings_helper. (me_flet_labels): Don't call check_lambda_list. Expansion of the generated lambdas will do argument list checking. (expand_catch_clause): Pass form to expand_params. (do_expand): Don't call check_lambda_list. Pass form to expand_params.
* New awk variable fw for fixed-width delimiting.Kaz Kylheku2016-12-262-0/+100
| | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slots fw, fw-prev and fw-ranges. (sys:awk-state rec-to-f): New logic to handle self.fw. (sys:awk-let): New local fw symacro. * txr.1: Documented fw.
* Add qquot optimization for ranges.Kaz Kylheku2016-12-251-0/+10
| | | | | | * eval.c (optimize_qquote_form): Check for a rcons forms. If thearguments are nothing but quoted forms, convert to literal range.
* Bugfix: incorrect quasi-quoting over #R syntax.Kaz Kylheku2016-12-252-5/+5
| | | | | | | | | | | | | | | | | | | The issue is that ^#R(,(+ 2 2) ,(+ 3 3)) produces 4..6 rather than #R(4..6). 4..6 is, of course, the syntax (rcons 4 6) which evaluates to a range. Here we want the range to which it evaluates, not the syntax. * eval.c (expand_qquote_rec): Handle the case when the qquoted_form is a range atom: expand the from and to parts, and generate a rcons expression. Though this seems to be opposite to the previous paragraph, it's the right thing. * parser.y (range): Drop the unquotes_occurs case which produces rcons syntax. Produce a range object, always. This is the source of the problem: a (rcons ...) expression was produced here which was just traversed by the qquote expander as list. It's the expander that must produce the rcons expression.
* Fix inconsistency in regex-source.Kaz Kylheku2016-12-251-2/+8
| | | | | | | | | | | | | | | | If we compile the regex expression (compound "str*"), calling regex-source on the compiled regex object yields "str*". That, of course, is treated as regex character syntax if fed back to regex-compile, and the * becomes an operator. We want the source to be (compound "str*"). This happens because the AST optimizer reduces (compound X) -> X. * regex.c (regex_compile): If the optimized expression is just a character string atom S, then for the purposes of maintaining the source code, convert it to (compound S).
* Tweak terminology in some parser error messages.Kaz Kylheku2016-12-231-3/+3
| | | | | | | | | | | | Eliminate references to a "list expression". This term specifically denotes (list ...) and not any compound expression. * parser.y (define_clause): Change "unterminated list expression" to "unterminated define directive". (output_clause): Change "unterminated list expression" to "unterminated output directive". (list): Change "list expression" to "expression".
* bugfix: dynamic env handling in parallel bindingKaz Kylheku2016-12-232-18/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the parallel binding (let ((x s) (s 0) (y s)) ...), both x and y must bind to the prior value of s, not to the new value 0. We have the bug that if s is a special variable, the initialization of y sees the new dynamic environment which contains the new value, so x gets the previous, y gets new. This commit fixes it. * eval.c (reparent_env): New static function. (bindings_helper): Separate logic into two loops, for sequential and parallel binding, so we don't have to repeatedly test this condition in the loop body, and can think separately about each case and streamline it. Nothing new happens under sequential binding; the behavior that is wrong for parallel binding is right for sequential. Under parallel binding, what we do is reset the dynamic environment to the original one prior to each evaluation of an initform. Then if the evaluation changes to a new dynamic environment (a special variable is being bound), we notice this and hook the new environment into a local stack, changing it parent pointer. At the end, we install this stack as the new dynamic env. Thus each init form is evaluated in the original dynamic env. * tests/011/special-1.tl: New tests added.
* Use with-out-string-stream macro in test.Kaz Kylheku2016-12-231-5/+1
| | | | | * tests/011/special-1.tl (with-output-to-string): macro removed; with-out-string-stream used.
* Convert special-1 test from txr to tl.Kaz Kylheku2016-12-232-10/+9
| | | | | * tests/011/special-1.txr: Renamed to tests/011/special-1.tl and @(do ...) removed.
* doc: extended dialect notes about exceptions.Kaz Kylheku2016-12-221-0/+153
| | | | | * txr.1: New section comparing TXR Lisp exceptions with CL conditions, with a contrasting example.
* Last var may be omitted in iflet/whenlet/condlet.Kaz Kylheku2016-12-222-2/+44
| | | | | | | | * eval.c (me_iflet_whenlet): Allow the last binding to be (init-form) instead of (sym init-form), for situations in which sym is never used. * txr.1: Documented.
* bugfix: make clean not removing txr-win.exeKaz Kylheku2016-12-221-0/+1
| | | | | | | * Makefile (clean): Remove txr-win an txr-win-dbg executables if they exist. Because of this issue, stale txr-win executables got packaged in some Windows installer releases.
* doc: refer to sort function out of List Sorting.Kaz Kylheku2016-12-221-0/+18
| | | | | | * txr.1: The List Sorting section looks as if it describes all the support there is for sorting. Add references pointing to sort under Sequence Manipulation.
* doc: formatting under block/block*Kaz Kylheku2016-12-221-2/+2
| | | | | * txr.1: Address \*(TL not followed by whitespace in HTML version.
* doc: fix example comment under ifaKaz Kylheku2016-12-221-1/+8
| | | | | * txr.1: The "Rule 7" example is actually triggering Rule 6. Fix comment and add a Rule 7 example.
* Version 163.txr-163Kaz Kylheku2016-12-206-490/+527
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* comment change in expander.Kaz Kylheku2016-12-201-4/+3
| | | | | * eval.c (do_expand): Fix outdated comment about what forms are expanded like function calls.
* Different approach for specials in let/let*.Kaz Kylheku2016-12-201-36/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This addresses a problem with the new scheme for handling specials. If we let specials be bound in the lexical environment and then do the swizzle into the dynamic environment using sys:with-dyn-rebinds, that only works correctly for parallel bindings (and thus also for lambda and macro parameters). For sequential bindings, it exposes the possibility that a closure is created during the sequential binding which captures a would-be special variable while it is still in the lexical stage. That closure can be thrown out of there, so the sys:with-dyn-rebinds is never reached which swizzles the variable. The new scheme is very simple. When expanding a let, we tranform (s init) to (s (sys:dvbind s init)) if s is a special variable. This new sys:dvbind operator binds s to the value of the init expression in a newly created dynamic environment, and returns the #:unbound symbol, which is received by the lexical s. Problem solved. The only thing remains is that the let special operator must save and restore the dynamic environment. There is no need for sys:with-dyn-rebinds around the body of a let, but we keep that mechanism and approach for handling specials in argument lists. * eval.c (dvbind_s): New symbol variale. (bindings_helper): Lose the env_out argument; return the new environment. No caller uses the returned bindings any more. (op_let): Call bindings_helper in initializing expression of new_env. Save the dyn_env, and restore it after evaluating the body. (op_dvbind): New static function. (expand_vars): Lose the pspecials argument. Perform the insertion of sys:dvbind. (do_expand): Simplify the let expander: expand_vars no longer outputs a list of specials and there is no need to insert with_dyn_rebinds_s. Add a case for sys:dvbind: assume it requires no expansion. (eval_init): Intern sys:dvbind, and bind it as an operator to the new op_dvbind function.
* tagbody bugfix: env not passed to expander.Kaz Kylheku2016-12-201-1/+1
| | | | | | * share/txr/stdlib/tagbody.tl (tagbody): When calling sys:expand, env was left out due to wrong parenthesis placement.
* Bugfix: sys:unbound mechanism lacks hygiene.Kaz Kylheku2016-12-201-2/+2
| | | | | | | | | | | The genvim.txr program iterates over package symbols and encounters sys:unbound. It binds that to a local variable, creating a problem due to the special hack. Let's turn sys:unbound into a gensym. * eval.c (eval_init): Protect unbound_s from gc. Initialize unbound_s with an uninterned symbol created by make_sym.
* Remove more vestiges of old specials handling.Kaz Kylheku2016-12-201-6/+0
| | | | | | | | * eval.c (struct bindings_helper_vars): Remove de member. (copy_bh_env_handler): Remove copying of dynamic environment. (bindings_helper): Remove all code dealing with de. The sequential binding will no longer introduce a dynamic environment.
* doc: document place macro hashKaz Kylheku2016-12-201-0/+18
| | | | * txr.1: Describe *place-expander* variable.
* doc: document place expander hashes.Kaz Kylheku2016-12-201-0/+17
| | | | | * txr.1: Document *place-update-expander*, *place-clobber-expander* and *place-delete-expander*.
* doc: move with-gensyms section.Kaz Kylheku2016-12-201-33/+32
| | | | | * txr.1: with-gensyms moves from User-Defined Places to macros.
* New function: find-frames.Kaz Kylheku2016-12-203-4/+28
| | | | | | | | | | | | | * unwind.c (uw_find_frames_impl): New static function, made from uw_find_frame. (uw_find_frame): Reduced to wrapper around uw_find_frames_impl. (uw_find_frames): New function. (uw_late_init): Register find-frames intrinsic. * unwind.h (uw_find_frames): Declared. * txr.1: Documented.
* awk macro: endpont-exclusive ranges.Kaz Kylheku2016-12-202-4/+49
| | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-mac-let): Local macro sys:rng generalized to support code generation for ranges that exclude either endpoint. Local rng macro adjusted to target this new form. Local macros rng-, -rng, and -rng- added. * txr.1: Documented.
* Remove vestiges of old special binding scheme.Kaz Kylheku2016-12-191-66/+17
| | | | | | | | | | | | | | | | | | | | | Removing code which handles the special function argument (sys:special ...) which can occur ahead of the other arguments, indicating the names of arguments which require special binding. Removing code which handles (sys:special init-form var) bindings in let/let*. * eval.c (env_vbind_special): Function removed. (bind_args): Do not look for special list; no such thing occurs. Use env_vbind directly rather than env_vbind special. (bind_macro_params): Likewise. (funcall_interp): Streamlined by not having to check for presence of specials list and setting up the dynamic environment frame for it. (bindings_helper): Don't look for the (sys:special initform sym) syntax among the bindings.
* Changing how binding of special variables works.Kaz Kylheku2016-12-181-60/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old way: process, at expansion time, bindings in lambda lists and all binding constructs to find special variables (symbols marked special). Replace these bindings with an annotation. Then when the interpreter performs binding, the binding helper functions process these annotations. Also, if specials occur, wrap the construct in sys:with-save-specials to set up the necessary dynamic environment frame. The new way: process, at expansion time, bindings in lambda lists and binding constructs (which have been reduced to just let and let*). If special variables occur, then wrap the body in in sys:with-dyn-rebinds which re-binds specific symbols in the dynamic namespace, copying their value from their lexical binding. The lexical bindings are then replaced with the value sys:unbound, which indicates that the value should be resolved in the dynamic environment. * eval.c (with_saved_vars_s): Symbol variable removed. (with_dyn_rebinds_s): New symbol variable. (lookup_var, lookup_sym_lisp1): If a lexical binding contains the value sys:unbound, then continue the search through the dynamic environment; ignore the remaining lexical environments. (expand_params_rec): Bugfix: neglected collect of special variable in fallback case. (expand_params): Takes body environment, and returns two values as a cons cell. The additional return value is a body that is either the original body, or else is wrapped with sys:with-dyn-rebinds. Removed is the special variable hack inserted into the syntax. (expand_macrolet, expand_tree_cases): Adjust to new expand_params interface. (op_with_saved_vars): Static function removed. (op_with_dyn_rebinds): New static function. (expand_vars): Return list of special variables via pointer argument, rather than just a Boolean which indicates that specials are present. Transformation to special representation is removed. (expand_catch_clause): Adjust to new expand_params interface. (expand_save_specials): Static function removed. (do_expand): Adjust let/let* expansion to new expand_vars interface. Generate the sys:with-dyn-rebinds wrapping around the body. Adjust the defun, lambda and mac-param-bind expanders to the new expand_params interface. Recognize sys:with-dyn-rebinds and don't expand it; all places which generate this form have to expand the internals themselves. (eval_init): Remove initialization of with_saved_var_s, and its registration as an operator. Initialize with_dyn_rebinds_s with interned symbol, and register as operator.