summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* New negated equality test functions.Kaz Kylheku2016-11-011-0/+48
| | | | | | | | | * eval.c (eval_init): Register neq, neql and nequal intrinsics. * lib.h (neq, neql, nequal): New inline functions. * txr.1: Documented neq, neql and nequal
* Relax restrictions on dwim places.Kaz Kylheku2016-10-311-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No longer require the leftmost expression in a dwim place to itself be a place, except when the expression evaluates to a list, and the list is subject to an element deletion or a range operation. * eval.c (eval_init): Register dwim-set and dwim-del with one additional argument that the C functions now take. * lib.c (dwim_set, dwim_del): Take a new place_p argument which informs these functions whether the object they are operating on came from a syntactic place. The forbidden situations are diagnosed based on this flag: modification of the subrange of a list, or deletion of a list ref. Some error messages reworded. * lib.h (dwim_set, dwim_del): Declarations updated. * share/txr/stdlib/place.tl (defplace dwim): Produce a different update, clobber and delete expansion when the obj-place form isn't a place. In the non-place case, do not assign the result of the sys:dwim-set or sys:dwim-del operation back obj-place. Furthermore, pass a Boolean flag to sys:dwim-set and sys:dwim-del indicating which situation is the case: did the object argument come from a place or non-place. * txr.1: Documentation updated.
* lambda-set method: treat [struct ...] as place.Kaz Kylheku2016-10-301-0/+127
| | | | | | | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Change registration of dwim-set to only one required argument, with the rest variadic. * lib.c (lambda_set_s): New symbol variable. (dwim_set): Change to variadic function that takes all arguments other than the object/sequence being operated on as struct args *. Rewrite to do a test on the object type first, handling hashes and structs specially. (obj_init): Initialize lambda_set_s. * share/txr/stdlib/place.tl (defplace dwim): Rewritten for more generic syntax. The only argument required is obj-place; the other arguments are treated as a variable argument list, all treated uniformly. This eliminates the special handling of the default value for hash lookups. * args.h (args_count): New inline function. * txr.1: Updated documentation for dwim operator, which neglects to mention use over objects thanks to the lambda function. Documented lambda-set.
* Extend symbol-function accessor to methods.Kaz Kylheku2016-10-291-4/+31
| | | | | | | | | | | | | | | | | | * eval.c (looup_fun): Handle (meth ...) syntax. * share/txr/stdlib/place.tl (sys:get-fb): Function removed. (sys:get-fun-getter-setter): New function. (defplace symbol-function): Rework getter and setter using new function which works for method as well as regular function bindings. * txr.1: Documentation updated in several places. The mention of symbol-function in the list of place forms altered so it doesn't insinuate that the argument must be a symbol. Description of symbol-function updated. Also under the trace and untrace macros, a note added that tracing methods is possible.
* doc: erroneous claim about symbol-function.Kaz Kylheku2016-10-291-2/+2
| | | | | | | * txr.1: Fix description under fun operator which says that a macro expander is available via symbol-function. This is outdated; the symbol-macro function accesses macro bindings.
* doc: heading consistency in *load-path*Kaz Kylheku2016-10-291-1/+1
| | | | * txr.1: Only first word of heading is capitalized.
* doc: reference to nonexistent stream.Kaz Kylheku2016-10-291-1/+1
| | | | * txr.1: Under pprof, *std-output* corrected to *stdout*.
* Adding function tracing support.Kaz Kylheku2016-10-291-0/+62
| | | | | | | | | | | | | New variable *trace-output*, and macros trace and untrace. * lisplib.c (trace_set_entries, trace_instantiate): new static functions. (dlt_register): Register new functions to auto-load trace module. * share/txr/stdlib/trace.tl: New file. * txr.1: Documented.
* New awk capability: file/pipe I/O redirection.Kaz Kylheku2016-10-281-0/+154
| | | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state): New slot, streams. Holds hash table of open streams. New :fini finalizer which closes all streams. (sys:awk-state ensure-stream, sys:awk-state close-or-flush): New methods. (sys:awk-redir): New macro. (sys:awk-let): Bind new local macros ->, ->>, <-, !> and !<. (awk): Call finalizers on awk state to get all streams to close. * txr.1: Document new awk macros.
* doc: update list of syntactic places.Kaz Kylheku2016-10-271-1/+11
| | | | | | * txr.1: Listing last, butlast, nthlast, butlastn, ref, sub, hash-userdata, slot, qref, slot access dot notation, and sock peer. Redundant listing of rest removed.
* doc: hyphenate "top-level" consistently.Kaz Kylheku2016-10-271-7/+7
| | | | * txr.1: Around half a dozen toplevel -> top-level edits.
* Improve alet macro.Kaz Kylheku2016-10-261-12/+13
| | | | | | | | | | | | | | | | | | | | | | | The alet macro should always convert bindings to constants into symbol macros; the all-or-nothing logic should be applied to any remaining bindings. * share/txr/stdlib/place.tl (sys:r-s-let-expander): Generalize this function somewhat more by passing in the fallback binding symbol to use for bindings that can't be turned into symbol macros, instead of hard-coding them to let. (rlset, slet): Specify 'let when calling sys:r-s-let-expander. (alet): If there are any bindings with constantp init expressions, then recurse: produce an expansion which separates constantp from non-constantp using sys:r-s-let-expander. Pass 'alet as fallback binding symbol; thus the expansion will recurse back to alet, but without all the constantp bindings, if there are any. We then deal with those using the existing all-or-nothing logic (which simplifies slightly since it doesn't have to check for constantp any more). * txr.1: Revised description of alet.
* Fix tok-str semantics once again.Kaz Kylheku2016-10-261-11/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that when the regular expression is capable of matching empty strings, tok-str will extract an empty token immediately following a non-empty token. For instance (tok-str "a,b" /[^,]*/) extracts ("a" "" "b") instead of just ("a" "b"). This is a poor behavior and the way to fix it is to impose a rule that an empty token must not be extracted immediately at the ending position of a previous token. Only a non-empty token can be consecutive to a token. * lib.c (tok_str): Rewrite the logic of the loop, using the prev_empty flag to suppress empty tokens which immediately follow non-empty tokens. The addition of 1 to the position when the token is empty to skip a character is done at the bottom of the loop and a new last_end variable keeps track of the end position of the last extracted token for the purposes of extracting the keep-between area if keep_sep is true. The old loop is preserved intact and enabled by compatibility. * tests/015/split.tl: Multiple empty-regex test cases for tok-str updated. * txr.1: Updated tok-str documentation and also added a note between the conditions under which split-str and tok-str, invoked with keep-sep true, produce equivalent output. Added compatibility notes.
* last, butlast: become accessors, get optional arg.Kaz Kylheku2016-10-261-41/+110
| | | | | | | | | | | | | | | | | | | | * eval.c (optimize_qquote_form): Pass nil to default new argument of butlast. (me_whilet, me_iflet_whenlet): Likewise for last. (eval_init): Add optional argument to registration of last and butlast intrinsics. * lib.c (last, butlast): Support optional numeric argument, like in Common Lisp. * lib.h (last, butlast): Declarations updated. * share/txr/stdlib/place.tl (last, butlast): New place macros. * txr.1: Updated documentation. The description of last is now moved into the sequence functions section.
* sub function becomes accessor.Kaz Kylheku2016-10-261-3/+30
| | | | | | * share/txr/stdlib/place.tl (defplace sub): New place. * txr.1: Document sub as accessor.
* New accessors nthlast and butlastn.Kaz Kylheku2016-10-251-0/+165
| | | | | | | | | | | | | | * eval.c (eval_init): register nthlast and butlastn intrinsicis. * lib.c (nthlast, butlastn): New function. * lib.h (nthlast, butlastn): Declared. * share/txr/stdlib/place.tl (defplace nthlast, defplace butlastn): New places. * txr.1: Documented nthlast and butlastn.
* doc: bad formatting in PRNG warmup notes.Kaz Kylheku2016-10-241-1/+3
| | | | * txr.1: Fix .code element in the middle of text.
* doc: fix indentation under format.Kaz Kylheku2016-10-241-3/+1
| | | | | | * txr.1: Description of ! hanging indent directive, ironically, has wrong hanging indentation, due to stray misplaced .RE.
* doc: missing plurals in headings, missing .desc.Kaz Kylheku2016-10-231-2/+3
| | | | | | | | * checkman.txr (check-func): Check for excess elements in singular heading. Add exception for headings that have Operator and macro. * txr.1: Missing plural in chr-ixdigit and chr-xdigit heading. Same in hash-begin and hash-next, plus missing desc.
* Default to epoch time in time-parse.Kaz Kylheku2016-10-231-0/+10
| | | | | | | * lib.c (epoch_time): New static function. (time_parse): Default the struct tm to epoch. * txr.1: Documented.
* doc: spelling error new circle notation doc.Kaz Kylheku2016-10-231-1/+1
|
* Version 155.txr-155Kaz Kylheku2016-10-211-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Document circular printing.Kaz Kylheku2016-10-211-0/+144
| | | | | * txr.1: Documenting circular notation and the *print-circle* variable.
* Changes to the printing framework.Kaz Kylheku2016-10-201-19/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The print function now takes an optional boolean for pretty printing. The print method is also called with a third argument; hence structures can customize both standard printing and pretty printing. * lib.c (obj_print): Take pretty argument, and pass it down to obj_print_impl. This makes obj_pprint redundant. (obj_pprint): Function removed: it was identical to obj_print except for passing t down to obj_print_impl for the pretty argument. These two wrappers had started small and got bigger with identical changes done in parallel. (pprint): New function. (tostring, dump): Pass nil for pretty argument of obj_print. (tostringp): Use pprint instead of obj_pprint. * lib.h (obj_print): Declaration updated. (obj_pprint): Declaration removed. (print, pprint): Declared. * eval.c (prinl): Pass nil for pretty_p argument of obj_print. Do the stream defaulting here; obj_print doesn't do it. (pprinl): Pass t for pretty_p argument of obj_print, and do stream argument defaulting. (eval_init): Register print to new print function rather than directly to obj_print. Register pprint to new pprint function rather than obj_pprint. * hash.c (hash_print_op): Call obj_print_impl to print the :equal-based keyword, rather than obj_print. Pass down the pretty flag. All the other keywords are treated this way; this fixes an inconsistency. * match.c (dump_var): Call pprint instead of obj_pprint. * stream.c (formatv): Call obj_print, with a calculated pretty argument instead of switching between obj_pprint and obj_print. * struct.c (struct_inst_print): Except when in backward compatibility mode, call the object's print method in both pretty and regular printing mode, passing the mode as a third argument. * tests/012/oop.tl (defstruct animal): Support third argument in print method. Make it optional because there are some explicit calls which don't pass the argument. * txr.1: Documentation updated for print method and the print function. Revised text for some of the related functions. Added compat notes.
* doc: reduce-left fixes.Kaz Kylheku2016-10-201-2/+8
| | | | | * txr.1: Fixed grammar error and added clarification that the init-val isn't filtered through key-function.
* doc: fix incomplete range literal desc.Kaz Kylheku2016-10-201-0/+10
| | | | | * txr.1: describe from and to expressions of range literals.
* doc: fix incomplete hash literal desc.Kaz Kylheku2016-10-201-1/+8
| | | | * txr.1: describe key-value pairs of hash literals.
* Fix struct lit problem exposed by circular syntax.Kaz Kylheku2016-10-201-6/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The semantics of how struct literals come to life is poorly designed: namely, the slot-value pairs in the struct literal are used as the plist argument in a call to make-struct. This is wrong because the implied initializations are then clobbered by the structure type's :init and :postinit handlers, resulting in an object with slot values that don't match what is in the literal. When you add circular syntax to the mix, things get worse. Slots may be initialized with (sys:circ-ref ...) expressions corresponding to #<n># syntax. These expressions then get clobbered by the constructor actions before the circ_backpatch processes the syntax. * parser.y (struct): Use make_struct_lit rather than make_struct to instantiate struct object. * struct.tl (sys:struct-lit): Expand to a form which calls sys:make-struct-lit, rather than make-struct. * struct.c (struct_init): Register new make_struct_lit function as sys:make-struct-lit intrinsic. (make_struct_lit): New function. * struct.h (make_struct_lit): Declared. * tests/012/struct.tl: struct literal expansion test case updated. * txr.1: Updated documentation of struct literals. Added compat notes.
* Support nil env in env-fbind and env-vbind.Kaz Kylheku2016-10-151-0/+6
| | | | | | | | * eval.c (env_fbind, env_vbind): Allow env to be nil, indicating that the binding is to take place in the global environment. * txr.1: Documented.
* Version 154.txr-154Kaz Kylheku2016-10-151-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: defsymacro: runaway recursion.Kaz Kylheku2016-10-141-1/+1
| | | | | * txr.1: If a symbol macro expands to itself indirectly, the result isn't a loop but runaway recursion.
* doc: defsymacro rewording.Kaz Kylheku2016-10-141-8/+12
| | | | | * txr.1: Updating awkward wording, beginning with clumsy two-clause sentence joined by a colon.
* doc: small fix under format ~s directive.Kaz Kylheku2016-10-141-1/+3
| | | | | * txr.1: typeset print function name with .code so it turns to typewriter font and hyperlink.
* Adding family slot to socket addresses.Kaz Kylheku2016-10-131-4/+28
| | | | | | | | | | | | | | | A static slot indicating the address family simplifies code which wants to map a socket address to its family. * lisplib.c (sock_instantiate): Call sock_load_init before loading socket.tl rather than after, because socket.tl now references variables defined inside sock_load_init. * share/txr/stdlib/socket.tl (sockaddr, sockaddr-in, sockaddr-in6, sockaddr-un): New static slot, family. * txr.1: Documented family slots.
* doc: clarification under nullify method.Kaz Kylheku2016-10-131-1/+2
| | | | | | * txr.1: the nullify method need not return the object itself in the non-empty case; it may also return a sequence.
* find-max and find-min support hashes.Kaz Kylheku2016-10-121-2/+21
| | | | | | | * lib.c (find_max): Restructured to implement separately for vectors and lists. Support hash tables. * txr.1: Document find-min and find-max for hashes.
* New accessor: hash-userdata.Kaz Kylheku2016-10-121-7/+36
| | | | | | | | | | | | | | The get-hash-userdata function is now deprecated in favor of hash-userdata, which is an accessor. * hash.c (hash_init): Register hash-userdata as a synonym for the same function as get-hash-userdata. * share/txr/stdlib/place.tl (hash-userdata): New defplace. * txr.1: Document new accessor, marking get-hash-userdata as a deprecated synonym. Replace references to get-hash-userdata with references to hash-userdata.
* Include user data in hash read syntax.Kaz Kylheku2016-10-121-6/+24
| | | | | | | | | | | | | * hash.c (userdata_k): New keyword symbol variable. (hash_print_op): Print the userdata together with the hash flags as :userdata obj. (hashv): Parse out :userdata obj syntax from the argument list. This takes care of supporting it in the read notation and in the hash function. (hash_init): Initialize userdata_k. * txr.1: Documenting :userdata in hash read notation and hash function.
* Support gmtoff and zone in time struct.Kaz Kylheku2016-10-121-2/+34
| | | | | | | | | | | | | | * lib.c (gmtoff_s, zone_s): New symbol variables. (tm_to_time_struct): Copy tm_gmtoff and tm_zone into Lisp struct from struct tm, if the platform has these. (time_fields_to_tm): Zero/null-out the tm_gmtoff and tm_zone fields of the target structure, if the platform has them. (time_init): Intern the gmtoff and zone symbols, initializing the gmtoff_s and zone_s variables. Add the gmtoff and zone slots to the time struct. * txr.1: Documented new slots.
* doc: typo under html-encode*Kaz Kylheku2016-10-121-1/+1
| | | | * txr.1: necessary -> necessarily
* New function regex-from-trie.Kaz Kylheku2016-10-121-0/+28
| | | | | | | * filter.c (regex_from_trie): New static function. (filter_init): Register regex-from-trie intrinsic. * txr.1: Documented regex-from-trie.
* Support curried args in method and meth.Kaz Kylheku2016-10-091-15/+75
| | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (meth): Take trailing arguments and pass them down to method, which now accepts them. * struct.c (struct_init): Register method intrinsic to the function method_args instead of the method function. (method_args_fun): New static function. (method_args): New function. Behaves like method function if args is empty, otherwise creates a function by means of method_args_fun. * struct.h (method_args_fun): Declared. * tests/012/oop.tl: New test case. * tests/012/oop.expected: Updated. * txr.1: Documented new features in method and meth, revising the documentation in the process.
* Support curried arguments in umethod and umeth.Kaz Kylheku2016-10-091-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/struct.tl (umeth): accept variadic arguments. Evaluate them using the dwim brackets and pass to umethod. The (fun umethod) trick is used to refer to the umethod in the function namespace even if it is shadowed by a variable. * struct.c (struct_init): Update registration of umethod to reflect its new variadic argument signature. (umethod_args_fun): New static function. (umethod): Return a function based on umethod_fun, as before, if there are no variadic args. Otherwise, use umethod_args_fun which deals with them. * struct.h (umethod): Declaration updated. * tests/012/oop.tl: Modest testcase for umeth with curried argument. * tests/012/oop.expected: Updated. * txr.1: Updated documentation of umeth and umethod.
* Version 153.txr-153Kaz Kylheku2016-10-071-2/+2
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Check for self-assignment in replace_struct.Kaz Kylheku2016-10-071-0/+11
| | | | | | | | | * struct.c (replace_struct): If target and source are the same object, just do nothing and return target. * txr.1: Document self-assignment and return value of replace-struct.
* doc: mistakes in introduction of do operator.Kaz Kylheku2016-10-071-3/+3
| | | | | | * txr.1: Where do is being introduced, fix a statement that about op, which should be about do. Plus fix verb agreement.
* Version 152.txr-152Kaz Kylheku2016-10-041-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: ranges are immutable.Kaz Kylheku2016-10-041-2/+5
| | | | | * txr.1: document that ranges are immutable and expand the surrounding wording a bit.
* doc: small change under defstruct.Kaz Kylheku2016-10-041-1/+1
| | | | | * txr.1: describe slot specifier as (name init-form) rather than (symbol init-form).
* length and empty functions support ranges.Kaz Kylheku2016-10-041-11/+60
| | | | | | * lib.c (length, empty): Handle RNG in switch. * txr.1: Documented.