summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* * txr.1: Document quasiquote operator syntax.Kaz Kylheku2014-02-231-2/+147
|
* * eval.c (symbol_function): Retrieve the global macro binding if theKaz Kylheku2014-02-221-9/+26
| | | | | | | | | | | function lookup fails, and if that fails, retrieve the special operator binding. (fboundp): Report t if there is a global macro binding. * txr.1: Use "global" rather than "toplevel". Added note that the fun operator doesn't see macro bindings. Documented that symbol-function and fboundp see global macro bindings, and that symbol-function can retrieve a special operator binding.
* * eval.c (prinl, pprinl): New functions.Kaz Kylheku2014-02-221-4/+11
| | | | | | (eval_init): Registered as intrinsics. * txr.1: Documented.
* * parser.y: Allow the (. expr) syntax to denote expr.Kaz Kylheku2014-02-221-0/+27
| | | | | | | | | * eval.h: Declare existing lambda_s extern variable. * lib.c (obj_print, obj_pprint): print (lambda sym ...) as (lambda (. sym) ...) and (lambda sym) as (lambda (. sym)). * txr.1: document it.
* * eval.c (eval_intrinsic): We don't need to make an environmentKaz Kylheku2014-02-221-3/+105
| | | | | | | | | | | | | | | | | | here if the env parameter is nil. The low level environment lookup functions already handle nil. (do_eval): Do not type check the env argument for the ENV type. (expand_forms, expand): No need to default a missing menv to a blank environment; just use nil. (macro_form_p): Take menv parameter and switch to lookup_mac from gethash. (macroexpand_1, macroexpand): Use the environment parameter by using lookup_mac rather than gethash. (eval_init): Fix registration of macro_form_p to reflect new optional argument. * txr.1: Documented optional environment parameters in macro-form-p, macroexpand-1 and macroexpand. Documented macrolet.
* Implementing special variables with local overriding.Kaz Kylheku2014-02-211-13/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All predefined globals become special. * eval.c (special, with_saved_vars_s): New global variables. (mark_special, special_p): New functions. (bindings_helper): Takes new argument, include_specials. Now processes the special colon syntax for denoting special variables, setting up their values, taking care to observe whether the binding is parallel or sequential. (op_let, op_for): Pass new argument to bindings_helper. (op_each): Pass new argument to bindings_helper with a value of it, and deal with the colon annotations that emerge in the bindings. (op_defvar, regvar): Mark symbol as special. (op_with_saved_vars): New static function. (expand_vars): Takes new argument, returns a cons. Detects special variables among the vars and produces the colon syntax. (expand_catch_clause): Bugfix: this was using expand_vars on a parameter list. Now properly uses expand_params. (expand_save_specials): New static function. (expand): For the operators that are binding constructs, handle the new form of expand_vars which returns information about special variables. If specials occur, then generate the with-saved-vars form around the expansion which will save and restore their values. The expansion of vars done by expand_vars, together with the run-time actions of bindings_helper, do the rest. Speaking of which, the new with-saved-vars operator form is now expanded here too. (eval_init): Protect new variables special and with_saved_vars_s. Initialize special with new hash table. Store new interned symbol in with_saved_vars_s. Register op_with_save_vars in op_table. * txr.1: Documented specials.
* * eval.c (macro_form_p, macroexpand_1, macroexpand): New staticKaz Kylheku2014-02-201-0/+40
| | | | | | | functions. (eval_init): Registered new functions. * txr.1: Documented.
* Fixing a long-running issue in the TXR pattern language: prematureKaz Kylheku2014-02-191-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | opening of files, prior to directives that actually need data. The documentation basically lied that this is the case: namely, the text "A file isn't opened until the query demands material from that file, and then the contents are read on demand, not all at once." This is now a fact. * match.c (non_matching_directive_table): New global variable. (open_data_source): New static function. Contains an almost verbatim migration of the source-opening logic that used to be in match_files. The useless assignment to c->nil is gone, and c->data == t is explicitly tested for. Instead of assuming that only the @(next) directive does not need to have a data source open, the table of non-matching directives is consulted. Opening the data source is now skipped for numerous directives. (match_files): Call open_data_source within the loop. This means that even after processing numerous non-matching directives, we will still correctly set up the data lazy list. (dir_tables_init): Initialize non_matching_directive_table, protect from GC and populate with numerous directives. * txr.1: Improved documentation for @(next :args), and removed a description of the hack that a single @(next) at the top of the query suppressed the opening of the data source.
* * eval.c (env_hash): new function.Kaz Kylheku2014-02-181-0/+43
| | | | | | | | | | | | | | | | (eval_init): Register env and env_hash functions. Register prog_args and prog_args_full as *args* and *full-args*. * lib.c (timegm_hack): Invalidate env_list, after mucking with the environment via setenv and unsetenv. * txr.c (prog_args_full, prog_args): New global variables. (txr_main): Command-line processing converted to use TXR's library. Populates prog_args_full and prog_args. * txr.h (prog_args_full, prog_args): Declared. * txr.1: Documented *args*, *full-args*, env and env-hash.
* The mode argument in some stream-opening functions becomes optional.Kaz Kylheku2014-02-181-14/+19
| | | | | | | | | | * eval.c (eval_init): Change registration for open_file, open_tail and open_command. * stream.c (open_file, open_tail, open_command): mode_str argument defaulted. * txr.1: Updated.
* * stream.c (open_tail): Fix 2013-12-02 regression:Kaz Kylheku2014-02-181-3/+10
| | | | | | | | seek_to_end_p argument being ignored, with the behavior being no initial seek to the end. * txr.1: Clarified the behavior of the seek-to-end-p option.
* Typos.Kaz Kylheku2014-02-181-2/+2
|
* Version 80txr-80Kaz Kylheku2014-02-171-2/+2
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES, txr.vim, dep.mk: Updated.
* * eval.c (eval_init): Register gensym function as the gensymKaz Kylheku2014-02-171-0/+29
| | | | | | | | | | | | | | intrinsic, rather than gensymv. Register gensym_counter as *gensym-counter*. * lib.c (gensym): Handle missing prefix argument by defaulting the prefix to "g". (gensymv): Function removed. * lib.h (gensymv): Declaration removed. * txr.1: Fixed omission: missing documentation for gensym. Documented *gensym-counter*.
* * eval.c (op_tree_case): Removed superfluous handling ofKaz Kylheku2014-02-161-3/+8
| | | | | | | | nil parameter list; this is correctly handled by bind_macro_params. Added support for the colon symbol as an indication that the case is declined. * txr.1: Updated.
* New destructuring operators.Kaz Kylheku2014-02-161-0/+66
| | | | | | | | | | | | | | | | | * eval.c (tree_case_s, tree_bind_s): New symbol variables. (bind_macro_params): Bugfix: inappropriate exception thrown when atom matched against parameter list. Bugfix: nil being returned when atom matches empty parameter list. Added support for a new convention: if loose_p is the colon keyword, then exceptions are not thrown for destructuring mismatches; nil is returned instad. (op_tree_case, expand_tree_cases, expand_tree_case, op_tree_bind): New static functions. (expand): Handle tree_case_s and tree_bind_s. (eval_init): Intern tree-case and tree-bind symbols. Register the corresponding operator functions op_tree_case and op_tree_bind under these symbols in op_table. * txr.1: Documented tree-case and tree-bind operators.
* * eval.c (bind_macro_params): Bugfix: the :whole parameter mustKaz Kylheku2014-02-151-2/+167
| | | | | | | | | capture the entire form, not just the arguments. (expand): Apply rlcp to the result of macro expansion, if it has not set up source code location. (eval_init): Register rlcp as intrinsic. * txr.1: Start of macro documentation. Documented rlcp.
* A trivial change in the UTF-8 decoder allows TXR to handle null bytesKaz Kylheku2014-02-151-1/+8
| | | | | | | | | | | | | | in text. * utf8.h (UTF8_ADMIT_NUL): New preprocessor symbol. (utf8_decoder): New member, flags. * utf8.c (utf8_decoder_init): Initialize flags to 0. (utf8_decode): If a null byte is encountered in the input, then convert it to 0xDC00, rather than keeping it as zero, unless flags contains UTF8_ADMIT_NUL. * txr.1: Document handling of null bytes.
* * eval.c (eval_init): Registered hash_update_1 as intrinsic.Kaz Kylheku2014-02-141-1/+25
| | | | | | | | * hash.c (hash_update_1): New function. * hash.h (hash_update_1): Declared. * txr.1: Documented hash-update-1.
* Different approach: optional arguments on hash-isec and hash-uni allowKaz Kylheku2014-02-141-18/+12
| | | | | | | | | | | | | | | | | | | | | for more flexible joining of data from the hash tables. * eval.c (eval_init): Remove hash_guni and hash_gisec. Change registration for hash_uni and hash_isec to three arguments with one optional. * hash.c (hash_uni): Third parameter introduced, join_func. The default behavior changes: in the two argument case, clashing keys prefer the value from hash1 rather than hash2. For this reason, we now iterate over hash2 first, then hash1. (hash_guni): Removed. (hash_isec): Third parameter introduced, join_func. (hash_gisec): Removed. * hash.h (hash_uni, hash_isec): Declarations updated. (hash_guni, hash_gisec): Delarations removed. * txr.1: Documentation updated.
* * eval.c (eval_init): Register hash_guni and hash_gisec as intrinsics.Kaz Kylheku2014-02-141-5/+18
| | | | | | | | | | | * hash.c (hash_guni, hash_gisec): New functions. (hash_isec): Bugfix: since gethash was naively used, keys in hash2 associated with the value nil were erroneously omitted from the intersection. * hash.h (hash_guni, hash_gisec): Declared. * txr.1: Documented new functions.
* * eval.c (eval_init): Register inhash as intrinsic.Kaz Kylheku2014-02-141-0/+38
| | | | | | | | | * hash.c (inhash): New function. * hash.h (inhash): Declared. * txr.1: Documented inhash. Also, added surprisingly missing documentation for gethash!
* * hash.c (hash_equal_op, hash_hash_op): New static functions.Kaz Kylheku2014-02-121-12/+25
| | | | | | | (hash_ops): New functions registered in table of operations. * txr.1: Documentation for equal function updated to explain how two hashes are equal.
* * eval.c (eval_init): Register new functions posqual, posql,Kaz Kylheku2014-02-111-0/+62
| | | | | | | | | | posq, pos, and pos_if as intrinsics. * lib.c (posqual, posql, posq, pos, pos_if): New functions. * lib.h (posqual, posql, posq, pos, pos_if): Declared. * txr.1: Documented
* * eval.c (eval_init): Turn a require argument into an optionalKaz Kylheku2014-02-111-4/+5
| | | | | | | | | | one for the functions some, all and none. * lib.c (some_satisfy, all_satisfy, none_satisfy): Add defaulting behavior for pred parameter. * txr.1: Document that the predicate function is optional in calls to some, all and none.
* Version 79txr-79Kaz Kylheku2014-02-111-2/+2
|
* * combi.c (comb_hash_while_fun, comb_hash_gen_fun, comb_hash): NewKaz Kylheku2014-02-111-6/+8
| | | | | | | | | | | | | static functions. (comb): Support hash tables. * hash.c (print_key_val): When values are nil, print in a more condensed way by omitting the second element. This notation is accepted as input already by the parser. (hash_insert_pair): New function. * txr.1: Description of comb updated to indicate that it works over hashes.
* Relaxed behavior: don't throw errors for impossible permutations,Kaz Kylheku2014-02-101-29/+37
| | | | | | | | | | | | | | | but return an empty list. * eval.c (perm_init_common): Do not throw error; return a nil state if permutation length exceeds sequence length. (perm_vec, perm_list, perm_str): Check for null return from perm_init_common and return empty list. (k_conses): Do not throw error; return empty list. (comb_list_gen_fun): Check for nil value out of k_conses. (comb): For vectors and strings, check length against k and return nil if necessary. For lists, comb_list_gen_fun handles it. * txr.1: Section order rearranged, and updated.
* * eval.c (rcomb_while_fun, rcomb_gen_fun_common,Kaz Kylheku2014-02-101-3/+29
| | | | | | | | rcomb_list_gen_fun, rcomb_list, rcomb_vec_gen_fun, rcomb_vec, rcomb_str_gen_fun, rcomb_str, rcomb): New static functions. (eval_init): Register rcomb as intrinsic. * txr.1: Documented rcomb.
* * eval.c (rperm, perm_str): Just in case, return a mutable emptyKaz Kylheku2014-02-101-0/+26
| | | | | | | | | | string, rather than null_string, which is a literal. (k_conses, comb_while_fun, comb_gen_fun_common, comb_list_gen_fun, comb_list, comb_vec_gen_fun, comb_vec, comb_str_gen_fun, comb_str, comb): New static functions. (eval_init): Registered comb as instrinsic. * txr.1: Documented comb.
* * eval.c (rperm_list, rperm_vec, rperm_str): n variable renamedKaz Kylheku2014-02-091-5/+36
| | | | | | | | | | | | | | | | | | to k, for consistency with rperm. (rperm): Likewise, and the behavior in the k == zero case is changed to return a single empty permutation. (perm_while_fun, perm_index, perm_gen_fun_common, perm_init_common, perm_vec_gen_fill, perm_vec_gen_fun, perm_vec, perm_list_gen_fill, perm_list_gen_fun, perm_list, perm_str_gen_fill, perm_str_gen_fun, perm_str, perm): New static functions. (eval_init): perm registered as intrinsic. * lib.c (vecref_l): Bugfix: allow negative indices, just like vecref. * lib.h (three, four): New macros. * txr.1: Updated documentation for rperm. Documented perm.
* * eval.c (nperm_while_fun, nperm_gen_fun, nperm_list,Kaz Kylheku2014-02-071-0/+36
| | | | | | | | nperm_vec_gen_fun, nperm_vec, nperm_str_gen_fun, nperm_str, nperm): New static functions. (eval_init): nperm registered as intrinsic. * txr.1: Documented nperm function.
* Version 78.txr-78Kaz Kylheku2014-02-061-2/+2
|
* * hash.c (hash_grow, make_hash, make_similar_hash, copy_hash):Kaz Kylheku2014-02-061-2/+3
| | | | | | | | | | | | | | | Pass second argument to vector. * lib.c (vector): Takes additional argument specifying the value for the slots of the vector. (vector_list, sub_vec): Pass second argument to vector. * lib.h (vector): Declaration updated. * eval.c (eval_init): Register vector as two-argument function with one required arg. * txr.1: Updated.
* * lib.c (generic_funcall): If a cons cell is passed asKaz Kylheku2014-02-051-0/+33
| | | | | | | one argument to a sequence being used as a function, split it into two arguments. This is consistent with the DWIM operator behavior. * txr.1: Document callable objects.
* * arith.c (lognot): Conform to new scheme for defaulting optional args.Kaz Kylheku2014-02-051-68/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (apply): Unconditionally use colon_k for missing optional args, for intrinsic functions. (eval_intrinsic, rangev, rangev_star, errno_wrap): Conform to new scheme for defaulting optional args. (reg_fun_mark): Function removed. (eval_init): Switch reduce_left and reduce_right back to reg_fun registration. * hash.c (gethash_n): Conform to new scheme for defaulting optional arguments. * lib.c (sub_list, replace_list, remove_if, keep_if, remove_if_lazy, keep_if_lazy, tree_find, count_if, some_satisfy, all_satisfy, none_satisfy, search_str, match_str, match_str_tree, sub_str, replace_str, cat_str, tok_str, intern, rehome_sym, sub_vec, replace_vec, lazy_str, sort, multi_sort, find, find_if, set_diff, obj_print, obj_pprint): Conform to new scheme for defaulting optional arguments. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Remove references to removed mark_missing_args member of struct func. (func_set_mark_missing): Function removed. (generic_funcall): Unconditionally use colon_k for missing optional args, for intrinsic functions. * lib.h (struct func): mark_missing_args member removed. (func_set_mark_missing): Declaration removed. (default_arg, default_bool_arg): New inline functions. * rand.c (random): Left argument is not optional. (rnd): Conform to new scheme for defaulting optional arguments. * regex.c (search_regex, match_regex): Conform to new scheme for defaulting optional arguments. * stream.c (unget_char, unget_byte, put_string, put_char, put_byte, put_line): Conform to new scheme for defaulting optional arguments. * syslog.c (openlog_wrap): Conform to new scheme for defaulting optional arguments. * txr.1: Remove the specification that nil is a sentinel value in default arguments, where necessary. Use consistent syntax for specifying variable parts in argument lists. A few errors and omissions addressed.
* * eval.c (bind_args): Support optional parameters in theKaz Kylheku2014-02-051-11/+18
| | | | | | | | form (sym initform present-p-sym). Also, support the convention that a value of : explicitly passed for an optional argument produces the same behavior as if that argument value were missing. * txr.1: Document new conventions.
* * eval.c (apply): Pass missing optional arguments as colon_k.Kaz Kylheku2014-02-051-8/+14
| | | | | | | | | | | | | | | | | | | | | | | to functions for which this is requested. (reg_fun_mark): New static function. (eval_init): Register reduce_left and reduce_right as requiring marking for missing optionals. * lib.c (func_set_mark_missing): New function. (generic_funcall): Pass missing optional arguments as colon_k to functions for which this is requested. (reduce_left, reduce_right): Handle missing values of init and key. (func_f0, func_f1, func_f2, func_f3, func_f4, func_n0, func_n1, func_n2, func_n3, func_n4, func_n5, func_n6, func_n7, func_f0v, func_f1v, func_f2v, func_f3v, func_f4v, func_n0v, func_n1v, func_n2v, func_n3v, func_n4v, func_n5v, func_n6v, func_n7v): Initialize new mark_missing_args member of struct func. * lib.h (struct func): New bitfield member, mark_missing_args. (func_set_mark_missing): Declared. (missingp, null_or_missing_p): New inline functions. * txr.1: Updated descriptions of reduce-left and reduce-right.
* Tighten up environment visibility semantics of default argumentKaz Kylheku2014-02-031-2/+2
| | | | | | | | | | | | | | | init forms, while streamlining the implementation. * eval.c (bind_args): Get rid of opt_init_parm array hack; turns out we already have a useful function for extending an environment object, namely env_vbind: hitherto unused! We now make a blank environment upfront and extend it destructively with env_vbind. Except that after evaluating an init form, we create a new environment: this is in case a lexical closure was made by the init form, in which event we don't want to be destructively manipulating the environment any more. * txr.1: Clarified.
* * txr.1: Mention that regular expression character classes haveKaz Kylheku2014-02-021-0/+2
| | | | no locale-dependent silliness.
* Adding list* since we get it "for free" thanks to theKaz Kylheku2014-02-021-0/+36
| | | | | | | | | new helper function that supports apply. * eval.c (list_star_intrinsic): New static function. (eval_init): Register list_star_intrinsic as list*. * txr.1: Document list*.
* append can now take additional leading arguments before the list.Kaz Kylheku2014-02-021-19/+25
| | | | | | | | | | | | | * eval.c (apply_frob_args): New static function. (apply_intrinsic): Process arguments with apply_frob_args. (eval_init): apply_intrinsic registered differently, as a variadic function with one mandatory arg. * lib.c (lastcons): New function. * lib.h (lastcons): Declared. * txr.1: Updated append documentation.
* * txr.1: Clarify that arbitrary expressions cannot be usedKaz Kylheku2014-02-021-3/+11
| | | | in the dot position of a function call form.
* * eval.c (apply): Support string and vector arglist.Kaz Kylheku2014-02-021-8/+16
| | | | | | | | | | | (do_eval_args): Support string or vector in dot position. * lib.c (tolist): New function. * lib.h (tolist): Declared. * txr.1: Document how apply and dot position in compound forms supports strings as well as vectors.
* * eval.c (do_eval_args): If the dotted position of the argumentKaz Kylheku2014-02-021-2/+61
| | | | | | | list evaluates to a vector, then convert the vector to a list. * txr.1: Document compound forms, and how they allow the dotted position and how it may be a vector.
* * eval.c (eval_init): Register vector_list function a second timeKaz Kylheku2014-02-021-0/+12
| | | | | | under the name vec, as a variadic function. * txr.1: Document vec.
* * txr.1: Fix bad directives example. Regexes are prefixed by #.Kaz Kylheku2014-02-021-1/+1
|
* * txr.1: Fix bad grammar.Kaz Kylheku2014-02-021-3/+3
|
* * txr.1: Documented forbidden hash table configuration ofKaz Kylheku2014-02-011-0/+3
| | | | weak keys that are equal-based.
* Version 77txr-77Kaz Kylheku2014-01-291-2/+2
|