summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Start of fallback package list implementation.Kaz Kylheku2016-11-165-11/+72
| | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register package-fallback-list and set-package-fallback-list intrinsics. * lib.c (package_fallback_list, set_package_fallback_list, intern_fallback): New functions * lib.h (package_fallback_list, set_package_fallback_list, intern_fallback): Declared. * parser.y (sym_helper): Slightly restructure function so that the symbol interning is done separately in the various cases. In the unqualified symbol case, use intern_fallback to search the fallback list of the current package. * share/txr/stdlib/package.tl (defpackage): Implement :fallback clause.
* Adjust some gen-gc array sizes.Kaz Kylheku2016-11-151-2/+2
| | | | | | | | | | | | | | Tuning some parameters by experimenting with timings. * gc.c (CHECKOBJ_VEC_SIZE): Reduce to 2*HEAP_SIZE; this doesn't have to be equal in size to FRESHOBJ_VEC_SIZE; entries into the checkobj array are not expected to be as frequent as in the freshobj array. (MUTOBJ_VEC_SIZE): On the other hand, at HEAP_SIZE/4, this may be too small. Increasing to 2*HEAP_SIZE. Overall, the storage for these arrays is reduced by over 25%, with seemingly better performance.
* Version 158.txr-158Kaz Kylheku2016-11-156-520/+545
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: fixes under equal method.Kaz Kylheku2016-11-151-2/+4
| | | | * txr.1: clarification; article-noun plurality agreement.
* mpi: must clamp result of conversion to bignum.Kaz Kylheku2016-11-151-0/+3
| | | | | | * mpi/mpi.c (mp_set_uintptr, mp_set_double_intptr): The value of z might not require all of the digits implied by the size of its C data type. We must clamp the result to trim trailing zero limbs from the bignum.
* New arithmetic tests.Kaz Kylheku2016-11-153-0/+42
| | | | | | | | | * Makefile (TXR_DBG_OPTS): Suppress for new directory tests/016. * tests/016/arith.tl: New file. * tests/016/arith.expected: New file.
* Fix bad mutation in arg handling.Kaz Kylheku2016-11-151-2/+1
| | | | | | | | * args.h (args_atz): Do not zap the car field of the first list cons; rather, zap the list itself. The list shouldn't be modified because in apply calls, it is a data structure belonging to the caller.
* mpi: eliminate trailing whitespace.Kaz Kylheku2016-11-142-104/+69
| | | | | | | | | * mpi/mpi-config.h: Eliminate several trailing spaces. * mpi/mpi.c: Eliminate all trailing spaces. Removed some commented-out code, and adjusted brace placement and indentation in one place. Also removed some spurious blank lines.
* Fix bug in bignum addition.Kaz Kylheku2016-11-141-1/+1
| | | | | | | | | * mpi/mpi.c (s_mp_add): It looks like this function had the same kind of bug I fixed years ago in the multiplication routines. ("fix-mult-bug" patch, originally). In the main loop, two digit-sized values are added together to produce a partial sum with carry. Unfortunately, both operands digit-sized, so the result is truncated to the digit type. The cast of one of the operands to mp_word is missing.
* Switch to user package before entering repl.Kaz Kylheku2016-11-141-0/+1
| | | | | | * txr.c (txr_main): The file loaded by the -i command line argument could manipulate *package*. Let's reset *package* to the user package before running the REPL.
* Introducing struct instance dirty flags.Kaz Kylheku2016-11-143-1/+119
| | | | | | | | | | | | | | | | * struct.c (struct struct_inst): New bitfield member, dirty. (struct_init): Register test-dirty, test-clear-dirty and clear-dirty intrinsics. (make_struct): Initialize dirty flag to 1. (slotset): If the object is clean, then determine whether the slot being set is an instance slot. If so, then set the dirty flag. (test_dirty, test_clear_dirty, clear_dirty): New functions. * struct.h (test_dirty, test_clear_dirty, clear_dirty): Declared. * txr.1: Documented dirty flags concept and new functions.
* New in-package macro.Kaz Kylheku2016-11-143-1/+33
| | | | | | | | | * lisplib.c (package_set_entries): Add in-package symbol name to autload list. * share/txr/stdlib/package.tl (in-package): New macro. * txr.1: Documented.
* Version 157.txr-157Kaz Kylheku2016-11-146-646/+705
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Fix spectacular bug in number of syntactic places.Kaz Kylheku2016-11-131-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Test case: (symacrolet ((f g)) (set [f x] y)) fails to expand. The root cause is that f is not expanded, because a nil environment is passed down to with-update-expander macro. This problem affects not only the dwim place, but nthcdr, sub and others. This bug was surprising at first because the Awk macro establishes the field array f via symbol macro. But assignments like (set [f 0] ...) worked! The thing is, they only worked by fluke due to the way expansions are handled in the Awk macro. That fluke came to an end in the November 4 commit db1fc32ebe29de61b0432a72385516a186f62a87, just before 156 was released. The changes there don't cause this problem, but they remove the circumstances which protect the awk macro from the problem. So yes, that commit effectively caused another regression in 156: assignment to awk fields not working. * share/txr/stdlib/place.tl (nthcdr, nthlast, ref, sub, dwim): Do not pass an environment value of nil to with-update-expander! Pass the value of the special variable sys:*pl-env* which is there exactly for this purpose: to give to place expanders like these the original macro environment where the form occurs, so they can expand embedded places.
* New functions for command or file I/O in one call.Kaz Kylheku2016-11-133-0/+301
| | | | | | | | | | | | | | | | * lisplib.c (getput_set_entries, getput_instantiate): New static functions. (dlt_register): Register auto-loading for getput module via new functions. * share/txr/stdlib/getput.tl: New file. * txr.1: Documented new functions file-get, file-put, file-append, file-get-string, file-put-string, file-append-string, file-get-lines, file-put-lines, file-append-lines, command-get, command-put, command-get-string, command-put-string, command-get-lines, and command-put-lines.
* Introduce case{q,ql,qual}* macros which eval keys.Kaz Kylheku2016-11-123-4/+95
| | | | | | | | | | | | | | * eval.c (caseq_star_s, caseql_star_s, casequal_star_s): New symbol variables. (me_case): Implement new macro semantics. (eval_init): Initialize new symbol variables, and register the symbols to the me_case macro expander. * tests/sock-common.tl (local-addr): This function depends on the old broken caseql semantics which evaluate keys. Using caseql* makes it work again. * txr.1: Document case{q,ql,qual}* macros.
* New :use-from clause in defpackage.Kaz Kylheku2016-11-112-4/+48
| | | | | | | | * share/txr/stdlib/package.tl (defpackage): Implemented new :use-from clause. * txr.1: Documented :use-from and made some improvements to the defpackage documentation.
* Clause in case{q,ql,qual} with no forms yields nil.Kaz Kylheku2016-11-112-5/+21
| | | | | | | | * eval.c (me_case): If forms is nil, substitute the object (nil) for forms, to ensure a nil result through the expansion to a cond. * txr.1: Documented and added compat notes.
* Bugfix in case{q,ql,qual} macro expansion.Kaz Kylheku2016-11-112-6/+35
| | | | | | | | | * eval.c (me_case): The key must be quoted unconditionally whether it's an atom or list. Let's make this subject to the compatibility flag in case someone's code depends on it. * txr.1: Compat notes added.
* vim: colorize #n= and #n#.Kaz Kylheku2016-11-113-17/+23
| | | | | | | | | * genvim.txr (txr_circ): New match. Link to Special highlight group. (txr_bracevar, txr_directive, txr_list, txr_mlist, txr_mbracket): Introduce txr_circ into these regions. * txr.vim, tl.vim: Regenerated.
* Add defpackage macro.Kaz Kylheku2016-11-113-0/+152
| | | | | | | | | | | * lisplib.c (package_set_entries, package_instantiate): New static functions. (lisplib_init): Register auto-loading for new package.tl file using new functions. * share/txr/stdlib/package.tl: New file. * txr.1: Documented.
* Streamline variable assignment operators slightly.Kaz Kylheku2016-11-111-15/+12
| | | | | | | | * eval.c (op_setq, op_lisp1_setq): Take the bindable(var) test out of the frequently executed path. We can safely do the variable lookup with any object. If the lookup fails, then we can complain that the object isn't a bindable symbol, if that is the case.
* Fix circular printing issue for package objects.Kaz Kylheku2016-11-101-1/+1
| | | | | | * lib.c (obj_print_impl): Print package name using ~a rather than ~s. Otherwise if the string object occurs elsewhere in the structure being printed, we have a problem.
* Handle interpreted functions in circle printing.Kaz Kylheku2016-11-102-0/+14
| | | | | | | | | | | | | | | | | | | Interpreted functions print as #<interpreted fun: name args>, thus repeating some list structure in their notation. This means we must traverse them when populating the object hash during printing, and also when backpatching after parsing. Test case: evaluate and print (let ((s '(lambda (a b c) d))) (list s (eval s))) with *print-circle* enabled. * lib.c (populate_obj_hash): Handle FUN objects of functype FINTERP. * parser.c (circ_backpatch): Likewise.
* Fix some gc-unsafe mutations found by inspection.Kaz Kylheku2016-11-102-3/+3
| | | | | | | | | | | | | | | | | | * eval.c (force): When replacing the promise by a forced value, we must use the set macro. Only the deref assignments which store symbols are safe, not the one storing ret. * lib.c (alist_nremove, alist_nremove1): We must use the set macro here instead of assigning through deref. Even though these assignments preserve the direction of the list (they just splice out nodes), it's possible that the list already contains a "wrong-way" reference (old generation to new) and that the node making this reference is appropriately marked to be processed properly in the next GC cycle. If we remove *that* node, we then cause its predecessor to point to the new generation node and that predecessor could be old generation.
* Check for non-package value in *package*.Kaz Kylheku2016-11-101-1/+9
| | | | | | * lib.c (get_current_package): If *package* contains nonsense, then reset it to a sane value and throw an exception.
* Implementing package foreign symbol concept.Kaz Kylheku2016-11-105-57/+667
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register new intrinsics: package-local-symbols, package-foreign-symbols, use-sym, unuse-sym, use-package, unuse-package, unintern. * gc.c (mark_obj): Mark new hidhash member of struct package. * lib.c (make_package): Initialize new hidhash member of struct package. (lookup_package): New static function. (find_package): Allow string or symbol argument. (get_package): New static function. (delete_package, package_symbols): Use get_package for flexible package argument; delete_package removes symbols from other packages via unuse_package. (package_local_symbols, package_foreign_symbols): New functions. (use_sym, unuse_sym): New functions. (resolve_package_designators): New static function. (use_package, unuse_package): New functions. (symbol_present): New static function. (intern): Revised with get_package for flexible package argument. (unintern): New function. (rehome_sym): Use get_package. Semantics revised. (obj_print_impl): Use symbol_present function to determine whether object is visible in *package* and can be printed without a prefix, rather than naive home package test. * lib.h (struct package): New member, hidhash. (package_local_symbols, package_foreign_symbols, use_sym, unuse_sym, use_package, unuse_package, unintern): Declared. * txr.1: Documentation updated. Extended section introducing the design of packages, and argument conventions. New functions described. Existing function descriptions revised, particularly rehome-sym. Missing description of delete-package added.
* Check that name is stringp in some sym functions.Kaz Kylheku2016-11-081-6/+18
| | | | | * lib.c (make_sym, make_package, intern): Check that the name argument is a string.
* Implement *package* special var; package overhaul.Kaz Kylheku2016-11-087-43/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (load): Rebind *package* in the local dynamic environment already established for the sake of *load-path*. By doing this we cause *package* to be restored to its prior value, which allows the loaded file to alter it. Common Lisp works this way. (eval_init): Register *package* variable, with the user package as its default value. * lib.c (package_s): New symbol variable. (intern, rehome_sym): Default the package argument to the current package, not to user_package. (get_user_package, get_system_package, get_keyword_package): Functions removed. (get_current_package): New function. (obj_print_impl): Revise symbol printing. Keyword and uninterned symbols are printed with : and #: prefixes. The remainder are printed with a package prefix if their home package isn't the current package. * lib.h (keyword_package, user_package, system_package): These macros are just straight aliases for the global variables, not going through the lookup mechanism, which was pointless. (cur_package): New macro. (package_s): Declared. (get_current_package): Declared. * lisplib.c (lisplib_try_load): Establish a local dynamic environment, and bind the *package* variable to the user package which the library modules expect. * parser.c (find_matching_syms, provide_completions): Treat unqualified symbols in the current package rather than user package. * parser.y (sym_helper): Intern unqualified symbols in the current package, not user package. * txr.1: Document that the variables user-package, system-package and keyword-package should not be modified. Document the *package* special variable, and that intern and rehome-sym default their package argument to its value. (Here we get rid of wrong references to the undocumented variable *user-package*).
* Don't access *print-circle* in early init.Kaz Kylheku2016-11-081-1/+1
| | | | | | | | * lib.c (obj_print): Check that print_circle_s has been interned before trying to look it up as a variable. Otherwise the auto-load code will be triggered, and try to use a hash table that doesn't exist yet. This can happen when this code is called during early initialization.
* Deprecated undocumented *user-package* etc.Kaz Kylheku2016-11-082-4/+6
| | | | | | | | | | | * eval.c (eval_init): Do not register *user-package*, or *system-package* or *keyword-package* variables unless in compatibility mode. We don't document this in the compatibility notes since the variables are not documented. * tests/009/json.txr: Change use of *keyword-package* to keyword-package.
* Support #: reading for uninterned symbols.Kaz Kylheku2016-11-073-10/+92
| | | | | | | | | | | | | | * parser.l (BTKEY, NTKEY): Renamed to BTKWUN and NTKWUN ("keyword and uninterned") respectively. Include an optional match for the # character. (BTOK, NTOK): Refer to BTKEY and NTKEY respectively * parser.y (sym_helper): Implement uninterned symbols by detecting when the package name string is "#" and handling specially. * txr.1: Documented package prefixes and uninterned symbols.
* New #; syntax for erasing following object.Kaz Kylheku2016-11-078-17/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * parser.c (parser_circ_ref): Don't generate the circular reference if circular suppression is in effect. * parser.h (struct parser): New member, circ_suppress. We use this for suppressing the generation of circular #n# references in erased objects. * parser.l (grammar): Scan #; producing HASH_SEMI token. * parser.y (HASH_SEMI): New token. (hash_semis_n_expr, hash_semis_i_expr, ignored_i_exprs, ignored_n_exprs): New nonterminals, needed for supporting the use of #; in front of top-level forms. (spec): Use hash_semis_n_expr and hash_semis_i_expr instead of n_expr and i_expr. (r_expr): Support object erasure within nested syntax. (yybadtoken): Handle H_SEMI token. (parse): Initialize new circ_suppress member of parser struct to zero. * txr.1: Documented. * genvim.txr (txr_ign_par, txr_ign_bkt, txr_ign_par_interior, txr_ign_bkt_interior): New regions for colorizing erased objects (partial support). (txr_list, txr_bracket, txr_mlist, txr_mbrackets): Include erased objects by including regions txr_ign_par and txr_ign_bkt. * txr.vim, tl.vim: Regenerated.