summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Fix incorrect example and add one more approach.Kaz Kylheku2015-09-021-12/+38
| | | | | | | | HACKING: Fix wrong make_foo example which violates Rule One, by registering an uninitialized struct as a cobj handle, thereby making garbage traversable by gc. Also show alternative solution to the problem based on extending variable liveness via gc_hint.
* Unix password database access.Kaz Kylheku2015-09-013-0/+246
| | | | | | | | | | | | | | | * configure: Detect getpwuid, getpwuid_r and others. * sysif.c (passwd_s, name_s, gecos_s, dir_s, shell_s): New symbol variables. (setpwent_wrap, endpwent_wrap, fill_passwd, make_pwstruct, getpwent_wrap, getpwuid_wrap, getpwnam_wrap): New static functions. (sysif_init): Initialize new symbol variables. Create passwd structure type. Register setpwent, endpwent, getpwent, getpwuid and getpwnam intrinsics. * txr.1: Documented passwd structure and functions.
* Fix wrongly named hash_lit_s symbol.Kaz Kylheku2015-09-011-1/+1
| | | | | * eval.c (eval_init): Fix wrong name of hash_lit_s symbol; it should be sys:hash-lit and not sys:hash-construct.
* Document new time structure and functions.Kaz Kylheku2015-09-011-0/+65
| | | | | * txr.1: Document time struct, time-struct-local and time-struct-utc.
* Documenting stat structure.Kaz Kylheku2015-09-011-25/+47
| | | | | | * txr.1: stat structure described; places updated to refer to it rather than the old propertly list. Compatibility note added.
* Fix bad .meta/.metn formatting.Kaz Kylheku2015-09-011-5/+5
| | | | | * txr.1: Fixed incorrect macro use under in, mapdo, set, and getenv.
* equal comparison and hashing for structs.Kaz Kylheku2015-09-011-2/+36
| | | | | * struct.c (struct_inst_equal, struct_inst_hash): New functions. (struct_inst_ops): Wire new functions into operations table.
* Fix wrong description of :wholeKaz Kylheku2015-09-011-2/+32
| | | | | * txr.1: :whole doesn't bind the entire macro form. Added Dialect Note to compare with CL.
* Improve error for uncallable object.Kaz Kylheku2015-09-011-1/+1
| | | | | | * lib.c (generic_funcall): If the object is not callable, the overall message now will be "object <whatever> called as function: object is not callable".
* Remove useless comment that contains two typos.Kaz Kylheku2015-09-011-4/+0
|
* Time structure.Kaz Kylheku2015-08-313-0/+62
| | | | | | | | | | | | | * eval.c (eval_init): Register time-struct-local and time-struct-utc intrinsic funtions. * lib.c (time_s, year_s, month_s, day_s, hour_s, min_s, sec_s): New global symbol variables. (broken_time_struct, time_init): New static functions. (time_struct_local, time_struct_utc): New functions. (init): Call time_init. * lib.h (time_struct_local, time_struct_utc): Declared.
* Struct documentation.Kaz Kylheku2015-08-311-5/+750
| | | | * txr.1: New section on structs documenting functions and macros.
* Move stat functions to use a struct.Kaz Kylheku2015-08-306-37/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (init): Move hash_init and struct init before sysif_init. * share/txr/stdlib/path-test.tl (sys:path-test-mode, path-mine-p, path-my-group-p, sys:path-access, path-newer, path-examine): Convert to struct return of stat functions. * stream.c (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Global variable definitions removed from here. (stream_init): Initializations of moved global variables removed from here. * stream.h (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Declarations removed from here. * sysif.c (stat_s, dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, mtime_s, ctime_s): New global variables. (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k): Existing variables moved here. (stat_to_struct): New static function. (stat_impl): Use stat_to_struct, except under 113 compatibility. (sysif_init): Initialize new symbol variables. Make stat struct type. * sysif.h (stat_s, dev_s, ino_s, mode_s, nlink_s, uid_s, gid_s, rdev_s, size_s, blksize_s, blocks_s, atime_s, mtime_s, ctime_s): Declared.
* struct: 4-way set associative slot caches.Kaz Kylheku2015-08-302-13/+61
| | | | | | | | | | | * lib.h (SLOT_CACHE_SIZE): Adjust value from 32 to 8. (slot_cache_entry_t): New struct typedef. (slot_cache_line_t): Typedef updated: a cache line consists of cache line entry structs rather than cnums. * struct.c (cacheline_lookup, cacheline_insert): New static functions. (lookup_slot): Use cacheline_lookup and cacheline_insert.
* Introducing structs.Kaz Kylheku2015-09-0215-6/+636
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_cat_zap): New function. * args.h: (args_cat_zap): Declared. * eval.c (struct_lit_s): New symbol variable. (eval_init): Initialize struct_lit_s. * eval.h (struct_lit_s): Declared. * gc.c (finalize): If a symbol has a struct slot hash attached to it, we must free it when the symbol is reclaimed. * lib.c (make_sym): Initialize symbol's slot_cache pointer to null. (copy): Copy structure objects. (init): Call struct_init to initialize struct module. * lib.h (SLOT_CACHE_SIZE): New preprocessor symbol (slot_cache_line_t, slot_cache_t): New typedefs. (struct sym): New member, slot_cache. * lisplib.c (struct_set_entries, struct_instantiate): New static functions. (liplib_init): Register new functions in dl_table. parser.y (HASH_S): New terminal symbol. (struct): New grammar rule. (n_expr): Derive struct. (yybadtoken): Map HASH_S to #S string. parser.l (grammar): Recognize #S and return HASH_S token. share/txr/stdlib/place.tl (slot): New defplace. share/txr/stdlib/struct.tl: New file. struct.c: New file. struct.h: New file. * Makefile (OBJS): Adding struct.o.
* Document alternation syntax.Kaz Kylheku2015-08-291-0/+8
| | | | | * txr.1: The { x | y } notation has been used in the document for a long time; now it is explained.
* Print parser error message for parse-time exceptions.Kaz Kylheku2015-08-291-3/+25
| | | | | | * parser.y (parse_once, parse): Catch error exceptions coming out of yyparse, print message, then re-throw. This way we see the file and line number near where that happened.
* Renaming c_true to tnil.Kaz Kylheku2015-08-275-25/+25
| | | | | | | | | | | | | | | | | | | | Macros called c_* should produce C counterparts of Lisp val objects, like c_num and c_str. * lib.h (c_true): Renamed to tnil. * eval.c (lexical_var_p, lexical_fun_p): c_true to tnil. * lib.c (less, chr_isalnum, chr_isalnum, chr_isalpha, chr_isascii, chr_iscntrl, chr_isdigit, chr_isgraph, chr_islower, chr_isprint, chr_ispunct, chr_isspace, chr_isblank, chr_isunisp, chr_isupper, chr_isxdigit, chr_toupper, keywordp): Likewise. * stream.c (catenated_stream_p): Likewise. * sysif.c (wifexited, wifsignaled, wcoredump, wifstopped, wifcontinued): Likewise.
* Fix wrong HTML references caused by identical section names.Kaz Kylheku2015-08-251-2/+7
| | | | | | | | | | For instance, both entries in the TOC titled "Overview" navigate to the the same section when we click on them. * genman.txr (tagnum): New hash for counting duplicate occurrences of section title. (enumerate): New function for adding numeric suffix to titles which are the same as previously seen titles.
* Fix duplication in manpage.Kaz Kylheku2015-08-251-15/+1
| | | | | * txr.1: Verbatim exact duplicate of packagep documentation removed. Fixed duplicated mknod heading over description of chmod.
* Replace two-step initialization of args with macros.Kaz Kylheku2015-08-247-84/+55
| | | | | | | | | | | | | | | | | | | | | * args.h (args_init_list, args_init): Return the struct args * pointer. (args_decl_list, args_decl): New macros. * eval.c (apply, do_eval, expand_macro, op_dwim, op_catch, (mapcarl, lazy_mapcarl): Switch to new macros. * hash.c (hashl): Likewise. * lib.c (generic_funcall, lazy_appendl, maxl, minl, funcall, funcal1, funcall2, funcall3, funcall4, transpose, juxtv, do_and, do_or, do_iff, unique): Likewise. * match.c (h_fun, v_fun): Likewise. * stream.c (vformat): Likewise. * syslog.c (syslog_wrap): Likewise.
* Document previously undocumented command line options.Kaz Kylheku2015-08-242-0/+24
| | | | | | * txr.1: Documented --gc-debug, --vg-debug and --dv-regex. * txr.c (help): Cover above options.
* Compatibility <= 107 allows redefinition of builtins.Kaz Kylheku2015-08-242-1/+8
| | | | | | | | * eval.c (builtin_reject_test): Suppress the diagnostic against redefinition of built-in macros and operators if the compatibility is 107 or lower. The rejection appeared in 108. * txr.1: Document this compatibility behavior.
* Add maze generation to test suite.Kaz Kylheku2015-08-243-0/+154
| | | | | | | | | * Makefile (tst/tests/013/maze.out): Add TXR_ARGS. Disable gc-debugging for tests in new directory. * tests/013/maze.expected: New file. * tests/013/maze.tl: New file.
* New --yydebug option.Kaz Kylheku2015-08-243-0/+25
| | | | | | | | | | | * parser.y (have_yydebug): New global constant. (yydebug_onoff): New function. * parser.h (have_yydebug, yydebug_onof): Declared. (yydebug_onoff): New function. * txr.c (help): List --yydebug option. (txr_main): --yydebug option implemented.
* New function: shuffle.Kaz Kylheku2015-08-244-0/+66
| | | | | | | | * eval.c (eval_init): Register shuffle as intrinsic. * lib.c (shuffle): New function. * lib.h (shuffle): Declared.
* Regression: assignment to [hash x..y] not working.Kaz Kylheku2015-08-231-9/+7
| | | | | | | | | | In this case, x..y should just be treated as a cons cell key, not as a range. * lib.c (dwim_set): If range argument is a cons, only delegate to the replace function if the object isn't a hash. (dwim_del): Likewise.
* Remove unused args_limit.Kaz Kylheku2015-08-232-10/+0
| | | | | | * args.c (args_limit): Function removed. * args.h (args_limit): Declaration removed.
* Use of new args for function calls in interpreter.Kaz Kylheku2015-08-238-38/+152
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_copy_to_list): New function. * args.h (ARGS_MIN): New preprocessor symbol. (args_add_list): New inline function. (args_copy_to_list): Declared. * debug.c (debug): Args in debug frame are now struct args *. Pull them out nondestructively for printing using args_copy_to_list. * eval.c (do_eval_args): Fill struct args argument list rather than returning evaluated list. Dot position evaluation is handled by installing the dot position value as args->list. (do_eval): Allocate args of at least ARGS_MAX for the call to do_eval_args. Then use generic_funcall to invoke the function rather than apply. (eval_args_lisp1): Modified similarly to do_eval_args. (eval_lisp1): New static function. (expand_macro): Construct struct args argument list for the sake of debug_frame. (op_dwim): Allocate args which are filled by eval_args_lisp1, and applied to the function/object with generic_funcall. The object expression is separately evaluated with eval_lisp1. * match.c (h_fun, v_fun): Construct struct args arglist for the sake of debug_frame call. * unwind.c (uw_push_debug): args argument becomes struct args *. * unwind.h (struct uw_debug): args member becomes struct args *. (uw_push_debug): Declaration updated. * txr.1: Update documentation about dot position argument in function calls. (list . a) now works, which previously didn't.
* Large scale conversion to new way of handling arguments.Kaz Kylheku2015-08-2315-574/+775
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Function arguments are now allocated on the stack using alloca, in conjunction with the struct alloc header structure. The generic_funcall and apply functions are refactored for this, as are most functions that take variadic arguments. * args.c (args_add_list, args_cons_list): Functions removed. (args_normalize, args_normalize_fill): New functions. (args_get_checked): Draw arguments from list when array runs out. (args_copy, args_copy_zap): New functions. * args.h (ARGS_MAX): Reduced to 32. (ARGS_MIN): New preprocessor symbol. (args_init): Call args_init_list. (args_add2, args_add3, args_add4): New inline functions. (args_more): Take into account list, which may hold additional arguments. (args_two_more): New inline function. (args_normalize, args_normalize_fill): Declared. (args_get_list): Normalize all arguments into one list and return it. (args_get_rest, args_at, args_atz): New inline functions. (args_get): Draw arguments from list when array runs out. (args_clear): New inline function. * arith.c (maskv): Convert to new args. * eval.c (APPLY_ARGS): Preprocessor symbol removed. (bind_args): Converted to accept struct args. (apply): Function reduced down to trivial adapter which converts a list of arguments to args, and calls the new generic_funcall. (applyv): New static function: struct args wrapper around apply_intrinsic. (iapply): Converted to struct args. (call): Static function removed. The call intrinsic function binding now goes directly to generic_funcall. (list_star_intrinsic, interp_fun): Converted to struct args. (op_catch): Adjustments for bind_args, which requires a struct args arglist. (me_op): Must use the new minl and maxl, since minv and maxv don't take lists any more. (mapcarv, mappendv, lazy_mapcarv, lazy_mappendv, mapdov, weavev, or_fun, and_fun, tf, nilf, do_retf, do_apf, do_ipf, callf, do_mapf, mapf): Converted. (mapcarl): New function, like the old mapcarv. (eval_init): call_f initialized from generic_funcall rather than call. apply registered to applyv rather than apply_intrinsic. Registrations for zip, hash_from_pairs, vec, alist-remove, alist-nremove, and throw similarly updated to new or renamed functions. * eval.h (interp_fun, mapcarv): Declarations updated. (mapcarl): Declard. * hash.c (hashv): Converted to struct args. (hashl): New function. (hash_construct): Use hashl, not hashv. (hash_from_pairs, hash_list, group_by): Converted. * hash.h (hashv, hash_construct, hash_from_pairs, hash_list, group_by): Declarations updated. (hashl): Declared. * lib.c (appendv, nconcv, lazy_appendv): Converted to struct args. (lazy_appendl): New function. (multi): Converted. (listv): New function. (nary_op, plusv, mulv, logandv, logiorv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv): Converted. (maxl, minl): New functions, like old maxv and minv. (exptv, gcdv, lcmv, lessv, greaterv, lequalv, gequalv): Converted. (func_f0v, func_f1v, func_f2v, func_f3v, func_f4v): Converted. (func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted. (func_n0v, func_n1v, func_n2v, func_n3v, func_n4v): Converted. (func_n1ov, func_n2ov, func_n3ov): Converted. (generic_funcall): Converted to take struct args. (funcall, funcall1, funcall2, funcall4): Pass stack-allocated struct args as trailing arguments to variadic functions, and to generic_funcall. (do_curry_12_1_v): New struct-args-based static function, needed to implement curry_12_1_v now. (curry_12_1_v): Converted. (transposev): New function based on previous tranpose. (transpose): Now a wrapper for transposev. (do_chain, chainv, do_chand, chandv, do_juxt, juxtv, do_and, andv, do_or, orv, do_not, do_iff): Converted. (vectorv): New function. Implementation basis for vec intrinsic function. (alist_removev, alist_nremovev): New functions. (multi_sort): Switch from mapcarv to mapcarl. (unique): Converted. (uniq): Allocate struct args for calling unique. (obj_init): list_f function now based on new listv, rather than identity. * list.h (varg): New typedef. (struct func): All variadic function pointers converted to use struct args. (appendv, nconcv, lazy_appendv, multi, nary_op, plusv, minusv, mulv, gtv, ltv, gev, lev, numeqv, numneqv, maxv, minv, exptv, gcdv, lcmv, logadnv, logiorv, maskv, lessv, greaterv, lequalv, gequalv, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n1ov, func_n2ov, func_n3ov, generic_funcall, chainv, chandv, juxtv, adnv, orv, unique): Declarations updated. (lazy_appendl, listv, maxl, minl, transposev, vectorv, alist_removev, alist_nremovev): Declared. * stream.c (make_catenated_stream_v): New function. (aformat): Renamed to formatv. The recognition of the nil and t streams (standard output and string) is done here now. (vformat): Follow rename of aformat to formatv. (formatv): Function removed. Nobody calls this anymore. (stream_init): make-catenated-stream re-registered to new make_catenated_stream_v function. * stream.h (formatv): Declaration updated. (make_catenated_v): Declared. * syslog.c (syslog_init): syslog registred to syslog_wrapv. (syslog_wrapv): New function based on syslog_wrap converted to struct args. (syslog_wrap): Now wrapper for syslog_wrapv. * syslog.h (syslog_wrapv): Declared. * unwind.h (uw_throwv): New function. (uw_throwfv, uw_errorfv): Converted to struct args. * unwind.h (uw_throwv): Declared. (uw_throwfv, uw_errorfv): Declarations updated.
* Clarification about @rest in do/op syntax.Kaz Kylheku2015-08-231-9/+20
| | | | | | * txr.1: Make it clear that @rest is not inserted if meta-numbers or @rest is present. Move example to the end.
* Remove silly use of apply from open-files.Kaz Kylheku2015-08-211-5/+2
| | | | * stream.c (open_files, open_files_star): Refactored.
* Don't implement range and range* with variadic functions.Kaz Kylheku2015-08-211-15/+14
| | | | | | | | | * eval.c (rangev, range_star_v): Functions renamed to range and rangev, and take three arguments instead of an argument list. (rangev_func, range_star_v_func): Static functions renamed to range_func and range_star_func. (eval_init): Register of range and rangev as three-argument functions with all arguments optional.
* Missing notes about global lexical variables.Kaz Kylheku2015-08-201-8/+43
| | | | | | * txr.1: Note that TXR Lisp has global lexicals, and that some library variables are examples of such, and that defparm is defparameter in CL.
* Wording in description of quasiquote.Kaz Kylheku2015-08-201-2/+2
| | | | | * txr.1: An unquote's evaluation should be contrasted with the quasiquote's suppression of it, not with the quote.
* Version 113.txr-113Kaz Kylheku2015-08-144-4/+44
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Remove useless member from parser structure.Kaz Kylheku2015-08-192-3/+3
| | | | | | | * parser.c (parser_common_init): Use local variable to capture output of yylex_init, rather than yyscan structure member. * parser.h (struct parser): Member yyscan removed.
* Fix parser bug caused by wrong kind of weak hash table.Kaz Kylheku2015-08-191-1/+1
| | | | | | | | | | | | | | This bug causes the parser associated with a stream to suddenly disappear while reading forms from the stream. Parsing continues, but with a new parser which does not carry the lookahead token from the previous parse. So for instance, we miss the opening parenthesis of the next form. * parser.c (parse_init): The stream_parser_hash must be a hash table with weak keys, but not weak values. We want the association to go away only if the stream becomes unreachable, not if the parser becomes unreachable while the stream is still reachable.
* Provide conservative marking interface.Kaz Kylheku2015-08-193-29/+28
| | | | | | | | | | | | | | | | | | | GC now exports a function for marking something that might not be an object, instead of a function for testing. The previous way wasn't integrated with Valgrind properly, and didn't observe the FREE flag. * gc.c (gc_is_heap_obj): Function removed. (mark_obj_maybe): New static function, with body consisting of code moved from mark_mem_region. (mark_mem_region): Moved code replaced by call to mark_obj_maybe. (gc_conservative_mark): New function, wraps mark_obj_maybe. * gc.h (gc_conservative_mark): Declared. (gc_is_heap_obj): Declaration removed. * parser.c (yy_tok_mark): Use gc_conservative_mark instead of gc_is_heap_obj check and gc_mark.
* Fix broken @@@<n>/@@@rest references in quasiliterals.Kaz Kylheku2015-08-192-2/+6
| | | | | | | | * parser.y (quasi_meta_helper): When obj is a sys:var, leave it alone; don't add another layer of var. Also, do the same if it is a sys:expr. * tests/012/quasi.tl: Added test case.
* Quasiquote regression from 110.Kaz Kylheku2015-08-192-5/+13
| | | | | | | | | | | | | | | | The problem is that one-argument function calls like @(whatever arg) in a quasiliteral being turned into sys:var items. * parser.y (quasi_meta_helper): Remove bogus check on length. The default case is now var, so the var_s check actually matters. The integerp check for the argument of a var form didn't do anything because the entire if statment conditionally selected a useless goto. Removing it for consistent treatment of var items. * tests/012/quasi.tl: Some new test cases involving @rest. These new tests pass whether or not we have that integerp(second(obj)) test in the quasi_meta_helper function. Either way @rest and @@rest produce the same thing.
* Troff formatting macros must not generate control sequences.Kaz Kylheku2015-08-191-4/+4
| | | | | | | | Reported by Dave Love. * txr.1 (cod1, cod2, meti, TP*): When inserting material at the start of a line, add the \& zero width character, so the line isn't interpreted as a control sequence.
* Fix man page markup errors.Dave Love2015-08-171-22/+22
| | | | | * txr.1: Numerous misspellings of macro names are repaired.
* Better error reporting for some indirect calls.Kaz Kylheku2015-08-181-18/+24
| | | | | | | * lib.c (callerror): New static function. (generic_funcall): Use callerror to report errors against the function rather than the uninformative call: prefix. (wrongargs): Implement in terms of callerror.
* Bugfix: forgotten zaps could lead to spurious retention.Kaz Kylheku2015-08-171-3/+3
| | | | | * lib.c (generic_funcall): Added forgotten z() calls to zap arguments in some variadic cases.
* Streamlining format with new args module.Kaz Kylheku2015-08-171-66/+48
| | | | | | | | | | | * stream.c (vformat): split into a new function called aformat, and a small wrapper which retains the vformat name. (aformat): New function formed from most of vformat. Takes struct args * instead of va_list. (formatv): Big switch statement hack gone. Now the function fills in a struct args, allocated on the stack, with an accurate size based on the args list. This is passed directly to aformat.
* Start of new way of handling variable arguments.Kaz Kylheku2015-08-173-1/+162
| | | | | | | | * Makefile (OBJS): Add args.o object. * args.c: New file. * args.h: New file.
* Improved wording about auto-loading.Kaz Kylheku2015-08-161-5/+6
| | | | | * txr.1: In the stdlib variable description, rewrote the text describing the macro-time autoloading scenario.
* Detect alloca.Kaz Kylheku2015-08-151-0/+27
|
* Minor dependency fix in Makefile.Kaz Kylheku2015-08-151-3/+6
| | | | | | * Makefile (y.tab.c, y.tab.h, lex.yy.c): Express dependency of these on the configuration material via the DEP macro rather than directly. That way ABBREV can reflect over the dependency.