summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* Eliminate duplicated warning-suppressing function.Kaz Kylheku2016-11-284-12/+12
| | | | | | | | | | | | | | * eval.c (warning_continue): Static function removed. (no_warn_expand): Use uw_muffle_warning instead of removed function. * parser.y (warning_continue): Static function removed. (parse_once): Use uw_muffle_warning instead of removed function. * unwind.c (uw_muffle_warning): New function. * unwind.h (uw_muffle_warning): Declared.
* bugfix: awk macro spews warnings.Kaz Kylheku2016-11-282-9/+21
| | | | | | | | | | | | | | Rather than fix this in the awk macro, let's just have sys:expand block warnings. * eval.c (warning_continue, no_warn_expand): New static function. (eval_init): Change registration of sys:expand to point to no_warn_expand. * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander, sys:placelet-1): Remove ignwarn wrapping from sys:expand calls.
* Version 160.txr-160Kaz Kylheku2016-11-276-600/+652
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: update package example.Kaz Kylheku2016-11-271-16/+16
| | | | | | | | * txr.1: The example illustrating a module with private and public symbols is altered to show a superior practice: use a no-fallback package for the public symbols, and be in the private package when defining the module.
* doc: note about circular notation and hashes.Kaz Kylheku2016-11-271-0/+13
| | | | | * txr.1: Document that circular notation works with eql-based hash tables, but not equal-based.
* doc: grammar under str-inaddr-net.Kaz Kylheku2016-11-271-2/+2
| | | | | * txr.1: eliminate 'large enough to "covers"' with rewording.
* Warn about unbound functions.Kaz Kylheku2016-11-272-21/+25
| | | | | | | | | | | | | | * eval.c (do_expand): If a compound form doesn't expand into anything, then let us check whether it calls an unbound function, and issue a warning. * share/txr/stdlib/place.tl (sys:pl-expand): Move function definition ahead of first use to suppress unbound function warning. Eventually we will have a relaxed model of deferred warning about this. (sys:placelet-1): Suppress warnings around call to sys:expand because we are expanding a body into which we inserted function calls without inserting their definitions.
* bugfix: var environment in expansion of defun.Kaz Kylheku2016-11-271-1/+4
| | | | | | | | | * eval.c (do_expand): When expanding the body of a defun we must create a function shadowing environment which indicates that the function's name is in scope. This must not be done for defmacro; a defmacro doesn't introduce a function binding, and a macros's body doesn't have that macro in scope.
* Don't throw when printing (sys:quasi . atom).Kaz Kylheku2016-11-271-2/+2
| | | | | | | | | | | | | | | | | | | We do not have perfect read/print consistency for quasiliterals. Programs can construct quasiliterals which cause the printer to throw exceptions, or which don't print such that the same object is read back. However, at least we can handle some trivial cases. In particular, the object (sys:quasi . #<function>) occurs in the system, as the top-level binding of the quasi operator. With this change, we can print that instead of throwing. * lib.c (obj_print_impl): Check that a quasiliteral or quasi-list-literal is a list with at least one argument. Don't print (sys:quasi) or (sys:quasi . non-nil-atom) in the notation.
* bugfix: read-print consistency for @(expr).Kaz Kylheku2016-11-271-1/+1
| | | | | | | | * lib.c (obj_print_impl): Only print (sys:expr x . rest) as @x if rest is nil, and x is a cons. Otherwise we create read-print problems: (sys:expr x y) prints as @x, concealing y. And (sys:expr sym) prints as @sym which reads as (sys:var sym).
* doc: fix references to nonexistent title.Kaz Kylheku2016-11-261-4/+4
| | | | | * txr.1: References to EXCEPTIONS corrected to the correct Exceptions section title.
* New function to access exception subtype map.Kaz Kylheku2016-11-262-3/+120
| | | | | | | | | | * uwind.c (exception_subtype_map): New static function. (uw_late_init): Register exception-subtype-map intrinsic function. * txr.1: Exception types are described in more detail. A complete diagram of the existing hierarchyis given, and the exception-subtype-map funtion is documented.
* Expander warns about unbound variables.Kaz Kylheku2016-11-2613-32/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_exception): New static function. (eval_error): Reduced to wrapper around eval_exception. (eval_warn): New function. (me_op): Bind the rest symbol in a shadowing env to suppress watnings about unbound rest. (do_expand): Throw a warning when a bindable symbol is traversed that has no binding. (expand): Don't install atoms as last_form_expanded. * lib.c (warning_s, restart_s, continue_s): New symbol variables. (obj_init): Initialize new symbol variables. * lib.h (warning_s, restart_s, continue_s): Declared. * lisplib.c (except_set_entries): New entries for ignwarn and macro-time-ignwarn. * parser.c (repl_warning): New static function. (repl): Use repl_warning function as a handler for warning exceptions: to print their message and then continue by throwing a continue exception. * parser.y (warning_continue): New static function. (parse_once): Use warning_continue to ignore warnings. In other words, we suppress warnings from Lisp that is mixed into TXR pattern language code, because this produces too many false positives. * share/txr/stdlib/except.tl (ignwarn, macro-time-ignwarn): New macros. * share/txr/stdlib/place.tl (call-update-expander, call-clobber-expander, call-delete-expander): Ignore warnings around calls to sys:expand, because of some gensym-related false positives (we expand code into which we inserted some gensyms, without having inserted the constructs which bind them. * tests/011/macros-2.txr: Suppress unbound variable warnings from a test case. * tests/012/ifa.tl: Bind unbound x y variables in one test case. * tests/012/struct.tl: Suppress unbound variable warnings in some test cases. * uwind.c (uw_throw): If a warning is unhandled, then print its message with a "warning" prefix and then throw a continue exception. (uw_register_subtype): Eliminate the check for sub already being a subtype of sup. This allows us to officially register new types against t. (uw_late_init): Register continue exception type as a subtype of the restart type. Formally register warning type. * txr.1: Documented ignwarn.
* bugfix: quasilit read/print consistency, part 2.Kaz Kylheku2016-11-264-16/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this patch commit I'm addressing the issue introduced in part 1 that expressions in @(output) blocks are still using (sys:expr ...) wrapping, but are passed down to an evaluator which now expects unwrapped expressions now. As part of this change, I'm changing the representation of @expr from (sys:expr . expr) to (sys:expr expr). * eval.c (format_field): Adjust access to sys:expr expression based on new representation. (transform_op): Likewise. * lib.c (obj_print_impl): Likewise. * match.c (dest_bind): Likewise. (do_txeval): Likewise. (do_output_line): Likewise, in some compat code. Here is the fix for the issue: when calling tx_subst_vars, we pass a list of one element containing the expression, not wrapped in sys:expr. Previously, we passed a one-element list containing the sys:expr. * parser.y (o_elem): If a list occurs in the syntax, represent it as (sys:expr list) rather than (sys:expr . list). (list): Do the same for @ n_expr syntax. (expand_meta, make_expr): Harmonize with the representation change.
* bugfix: quasilit read/print consistency, part 1.Kaz Kylheku2016-11-264-42/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug is that `@@@a` prints as `@@a` which reads as a different object. In this patch we simplify how quasiliterals are represented. Embedded expressions are no longer (sys:expr E), just E. Meta-numbers N and variables V are still (sys:var N). However `@@a` and `@a` remain equivalent. * eval.c (subst_vars): No need to look for expr_s; just evaluate a compound form. The recursive nested case is unnecessary and is removed. (expand_quasi): Do nothandle expr_s; it is not part of the quasi syntax any more. * lib.c (out_quasi_str): Do not look for expr_s in the quasi syntax; just print any expression with a @ the fallback case. * match.c (tx_subst_vars): Analogous changes to those done in subst_vars in eval.c. * parser.y (quasi_meta_helper): Static function removed. This was responsible for the issue due to stripping a level of meta from expressions already having a meta on them. (quasi_item): In the `@` n_expr syntax case, no longer call quasi_meta_helper. The remaining logic is simple enough to put in line. Symbols and integers get wrapped with (sys:var ...); other expressions are integrated into the syntax as-is.
* bugfix: dohash expander not making shadowing env.Kaz Kylheku2016-11-251-1/+2
| | | | | | | | * eval.c (do_expand): When a dohash special form is expanded, a macro shadowing environment must be created for the two variables that it binds and the body must be expanded in that environment, to protect the variables from symbol macros.
* bugfix: expander traversing (sys:expr ...).Kaz Kylheku2016-11-251-1/+1
| | | | | | * eval.c (do_expand): Do not expand into (sys:expr ...) expressins, the same way (sys:var ...) expressions are avoided. They are not forms.
* bugfix: unbound var in IP-slash-notation functions.Kaz Kylheku2016-11-251-6/+6
| | | | | | * share/txr/stdlib/socket.tl (sys:str-inaddr-net-impl): Use let* so that calculation of we can see dependent w variable.
* bugfix: op handles @rest in dot position.Kaz Kylheku2016-11-251-1/+1
| | | | | | | | | | The test case is (op list . @rest) and similar, which were expanding to a syntax containing an incorrect form like [sys:apply list sys:var rest #:rest-0123] where the sys:var rest are superfluous. * eval.c (transform_op): Missing case: the code which handles metas in the dot position must handle @rest not only @<number>.
* bugfix: don't expand @meta syntax as function call.Kaz Kylheku2016-11-241-0/+2
| | | | | | * eval.c (do_expand): If the form is (sys:var ...) then skip it without expanding. Of course, that does not preclude it form being a macro.
* bugfix: op macro using wrong expansions op.Kaz Kylheku2016-11-241-1/+3
| | | | | | * eval.c (me_op): When the operator is op, the arguments must be expanded as Lisp-1 with expand_forms_lisp1, not with the regular expand_forms.
* macro-time: interleave evaluation and expansion.Kaz Kylheku2016-11-242-2/+19
| | | | | | | | | | * eval.c (do_expand): When expanding the macro-time form, do not macro-expand it entirely and then evaluate. Rather, expand each argument form and evaluate. This way earlier forms can make global definitions which are used while macro-expanding later definitions. * txr.1: Behavior documented.
* bugfix: broken test-inc macro.Kaz Kylheku2016-11-241-1/+1
| | | | | * share/txr/stdlib/place.tl (test-inc): Expander refers to unbound variable.
* bugfix: neglect to expand mac-param-bind forms.Kaz Kylheku2016-11-241-6/+19
| | | | | | | | | | | | | | The syntax of mac-param-bind forms isn't recognized at all in the expander, causing these forms to be incorrectly expanded as if they were function calls. * eval.c (mac_param_bind_s): New symbol variable. (do_expand): Handle mac_param_bind_s with the same block of code as tree_bind_s, adjusted to account for the small syntactic difference. (eval_init): Initialize mac_param_bind_s with interned symbol. Register operator using mac_param_bind_s to avoid redundant intern call.
* bugfix: macrolet args not included in macro env.Kaz Kylheku2016-11-241-29/+31
| | | | | | | | | | | | | | | When the function bodies of macrolets are themselves being macro-expanded, this is incorrectly being done in the original macro environment without taking into account the macrolet parameters which those bodies have in scope. Hence the parameters are not able to shadow symbol macros. * eval.c (make_var_shadowing_env): Moved above expand_macrolet so we can avoid adding a forward declaration. Otherwise unchanged. (expand_macrolet): For each macrolet function, create a shadowing environment which contains its parameters, and use that for expanding the body.
* bugfix: indicator params absent from macro envs.Kaz Kylheku2016-11-241-2/+5
| | | | | | | | | | | | | | The problem is about those Boolean parameters which indicate whether their associated optional parameters are present: in (lambda (: (opt-parm 42 opt-parm-p))), such a parameter is opt-parm-p. When parameter lists are walked by the macro expander, these parameters are not being included as shadow entries in macro-time parameter lists. Thus if opt-parm-p happens to shadow an outer symbol macro, that symbol macro will be expanded anyway. * eval.c (get_opt_param_syms): Function now lists those additional parameters.
* bugfix: reading hash literals with circ notation.Kaz Kylheku2016-11-231-1/+12
| | | | | | | | | | | | | | | | | | | The backpatching of literal hash objects containing circular notation labels is incorrect, because it directly mutates the hash keys, without regard for the fact that this alters their hash values. This change makes the test case #1=#H(() (#1# #1#)) work properly: a hash which contains itself as a key and corresponding value. When this object is constructed by the reader, we can do a gethash call on it, using itself as the key, and it emerges as the value. Before this fix, nil would be returned indicating that the key is not found, although it is listed in the table (corrupt hash). * parser.c (circ_backpatch): When traversing a hash, local list of the cells. Then clear the hash, iterate the list of old cells, and re-insert the key-value pairs.
* Adding clearhash function.Kaz Kylheku2016-11-233-0/+35
| | | | | | | | | | | | This is needed for an upcoming bugfix, so why not expose it as an intrinsic. * hash.c (clearhash): New function. (hash_init): clearhash intrinsic registered. * hash.h (clearhash): Declared. * txr.1: Documented clearhash.
* Move unwind intrinsics from eval.c to unwind.c.Kaz Kylheku2016-11-233-27/+28
| | | | | | | | | | | | | | | | * eval.c (reg_mac): Static function changed to extern. (me_defex, register_exception_subtypes): Static function removed here; relocated into unwind.c. (eval_init): Registrations of defex, throw, throwf, error, register-exception-subtypes and exception-subtype-p removed. * eval.h (reg_mac): Declared. * unwind.c (me_defex, register_exception_subtypes): Static function moved here. (uw_late_init): Registrations of defex, throw, throwf, error, register-exception-subtypes and exception-subtype-p moved here.
* doc: small revision in intro text.Kaz Kylheku2016-11-221-3/+3
| | | | * txr.1: Mention support for OOP.
* doc: misleading dialect note under symbol-function.Kaz Kylheku2016-11-221-2/+3
| | | | | | * txr.1: Fix text saying that symbol-function retrieves only functions; that is true for symbols, not for the compound syntax.
* doc: fixes under tagbody.Kaz Kylheku2016-11-221-2/+2
| | | | | | * txr.1: Grammar: to occurs -> to occur. Also any subforms of a tagbody form may be go, not just one one form as the text seems to be saying.
* doc: formatting fix under boundp.Kaz Kylheku2016-11-221-0/+2
| | | | * txr.1: Fix bad inline expression splitting.
* configure: search for working lex.Kaz Kylheku2016-11-221-2/+41
| | | | | | | | | * configure (lexname, lexname_given, lex_given): New variables. (lex): interpolate lexname (in make syntax). Inform about lexname in help text. (gen_config_make): Generate lexname make var. New lex test.
* doc: formatting issue in awk fconv macro desc.Kaz Kylheku2016-11-221-2/+2
| | | | | * txr.1: Fix two instances of clause parameter being typeset as .code rather than .meta.
* doc: fix in delimited continuations description.Kaz Kylheku2016-11-221-1/+1
| | | | * txr.1: Missing article: *the* sys:capture-cont function.
* doc: fixes under Symbols and Packages.Kaz Kylheku2016-11-221-2/+4
| | | | | * txr.1: Fix .code *package* embedded in paragraph. Remove stray words in code comment in package example.
* Version 159.txr-159Kaz Kylheku2016-11-216-632/+667
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* configure: move Darwin check into Makefile.Kaz Kylheku2016-11-202-15/+17
| | | | | | * Makefile (conftest.darwin): New phony target. * configure: Always do Darwin check via make conftest.darwin.
* Revive -b option for binding Lisp variables.Kaz Kylheku2016-11-202-9/+45
| | | | | | | | * txr.c (txr_main): Implement -b option that takes an argument. Ensure that -b produces an error if clumped with other options. * txr.1: Documented -b var=val.
* Conform to standard Makefile conventions.Kaz Kylheku2016-11-202-39/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | TXR's build should use the values of standard make variables: use the existing $(CC), $(CFLAGS), $(YACC), $(LDFLAGS) and such. * Makefile (TXR_CFLAGS): New variable. Initialized with the value of $(CFLAGS) and then customized. Used everywhere in place of CFLAGS. (CFLAGS): Now used only as the initial value of TXR_CFLAGS; no longer clobbered with the := assignment. Thus if a distribution of free software builds everything with certain CFLAGS, we incorporate those CFLAGS that it wants us to use. (TXR_LDFLAGS): New variable, initialized from $(LDFLAGS). Used in place of LDFLAGS. (LDFLAGS): Use only, do not modify. (NM): Replaced with TXR_NM. (YACC): Replaced with TXR_YACC. * configure (ccname): Default to $(CC) rather than gcc. (lex): Default name portion $(LEX) rather than flex; keep the optional prefixes. (gen_config_make): Generate TXR_CC, TXR_LEX, TXR_YACC and TXR_NM variables, rather than clobbering the standard ones CC, LEX and YACC. Also, in the rule that finds yacc, we now try '$(YACC)' first.
* Diagnose undefined functions in trace.Kaz Kylheku2016-11-192-2/+26
| | | | | | | | | * share/txr/stdlib/trace.tl (sys:trace): If symbol-function returns nil, throw exception. * txr.1: Document the behavior, along with return values of trace and untrace, and the tolerance of untrace to bad arguments.
* Allow global macros to be denoted by (macro sym).Kaz Kylheku2016-11-193-26/+131
| | | | | | | | | | | | | | | | | In this patch we allow (symbol-function '(macro sym)), (defun (macro sym) (form env) ...), and (trace (macro sym)). * eval.c (macro_s): New symbol variable. (lookup_fun, func_get_name, op_defun): Support (macro sym) syntax. (builtin_reject_test): Pass through (macro sym) syntax. (eval_init); Initialize macro_s. * share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Support macro place. * txr.1: Documented verything.
* Bugfix: cannot untrace individual method.Kaz Kylheku2016-11-191-1/+1
| | | | | * share/txr/stdlib/trace.tl (sys:*trace-hash*): Hash must be equal-based to correctly support compound places.
* Handle interpreted macros through function.Kaz Kylheku2016-11-192-38/+53
| | | | | | | | | | | | | | | | All macros are function bindings now. * eval.c (me_interp_macro): New function. Body is a copy of block from expand_macro. (op_defmacro): Hoist the me_interp_macro function into the object domain, installing the macro material as the environment. This function is the expander. (expand_macro): Assume that the binding is a function and call it. The cons case is gone. (expand_macrolet): Similar change to the one in op_defmacro: a macrolet is also a function. * txr.1: Documentation under symbol-macro updated.
* Use function rather than cptr built-in macros.Kaz Kylheku2016-11-191-51/+48
| | | | | | | | | | | * eval.c (mefun_t): Typedef removed. (expand_macro): Test whether the binding is a function, rather than C object, and call it with funcall2. (reg_mac): Take a val argument for the expander function, rather than a C function pointer, and just store that value into the binding unconverted. (eval_init): Insert a func_n2(...) call into all reg_mac calls to hoist the C functions into the object domain.
* Reproduce shared structure in sys:switch expansion.Kaz Kylheku2016-11-181-4/+36
| | | | | | | | | | | * eval.c (expand_forms_ss): New static function: like eval_forms but preserves shared substructure along the spine of the list. (expand_list_of_form_lists): Use expand_forms_ss instead of expand_forms, taking the required hash via a new parameter. (expand_switch): Instantiate the required hash table and pass down to expand_list_of_form_lists.
* Bugfix in expansion-time progn reduction.Kaz Kylheku2016-11-181-1/+1
| | | | | | | | | | | | | This was exposed by causing an issue in the multi-pass expansion strategy used in tagbody which shields macro forms from a global macro using a local macro. * eval.c (expand_progn): When calling constantp, pass the macro environment, as required, rather than nil. This was causing (go ...) forms in tagbody to be expanded in the global environment using the global go macro which unconditionally throws an error about an undefined label, rather than using the harmless local go macrolet.
* Adding a tagbody macro to the language.Kaz Kylheku2016-11-184-1/+305
| | | | | | | | | | | | | | | | | | | | | | | This is a "disciplined goto" feature of Common Lisp. This uses a new sys:switch operator, which could also be used for optimizing case and cond forms. * eval.c (switch_s): New symbol variable. (op_switch, expand_list_of_form_lists, expand_switch): New static functions. (do_expand): Hook in the expansion of the sys:switch operator. (eval_init): Initialize switch_s special variable to sys:switch symbol. Register sys:switch special op. * lisplib.c (tagbody_set_entries, tagbody_instantiate): New static functions. (lisplib_init): Register autoloading of tagbody module via new functions. * share/txr/stdlib/tagbody.tl: New file. * txr.1: Documented.
* Completion of fallback list implementation.Kaz Kylheku2016-11-166-25/+282
| | | | | | | | | | | | | | | | | | | | | | | | * lib.c (find_symbol): New function. (symbol_present): Search the fallback list also to determine whether the symbol is visible. * lib.h (find_symbol): Declared. * parser.y (sym_helper): Implement a new behavior for qualified symbols. Interning new symbols is only allowed for packages that have an empty fallback list. * parser.c (get_visible_syms): New static function. (find_matching_syms): Use get_visible_syms to get the list of eligible symbols. This way the fallback list of the package is included if it is the current package. * share/txr/stdlib/package.tl (defpackage): Do not insert a default (:use usr) if there is no :usr clause. Since defpackage is very new, no need for backward compatibility; the amount of code depending on this is likely zero. * txr.1: Documented fallback list feature.