summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Don't track macro origin of interned objects.Kaz Kylheku2016-11-041-1/+3
| | | | | | * eval.c (set_origin): If either form or origin isn't a heap object, or is an interned symbol, then don't record the relationship.
* Remove spurious slash in cadr autoload pathname.Kaz Kylheku2016-11-042-2/+2
| | | | | | | * cadr.c: Regenerated. * gencadr.txr (cadr_register): stdlib_path already has a slash; we don't have to add one.
* Don't print distracting path in error trace.Kaz Kylheku2016-11-041-2/+2
| | | | | | * eval.c (error_trace): No need to indicate where an expansion was calculated; it is distracting information when the exception isn't happening at expansion time.
* No need to track origin of entire macrolet.Kaz Kylheku2016-11-041-4/+1
| | | | | | | | | | * eval.c (expand_macrolet): Do not call set_origin to establish a macro ancestry link between the output of the expansion and the original macrolet block. This is not necessary. What is useful and important that the individual expansions of the actual macrolets have their origins tracked to the respective subforms of the original macrolet form. That's already taken care of by expand_macro.
* Show location of expanded form in exp-time errors.Kaz Kylheku2016-11-041-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Old behavior: | 1> (sys:expand '(defstruct foo bar)) | ** defstruct: inheritance base bar does | not name a struct type | ** during expansion at | /usr/local/share/txr/stdlib/struct.tl:120 | of form (defstruct foo bar) New behavior: | 1> (sys:expand '(defstruct foo bar)) | ** defstruct: inheritance base bar does | not name a struct type | ** during expansion at expr-1:1 of form (defstruct foo | bar) | ** by macro code located at | /home/kaz/txr/share/txr/stdlib/struct.tl:120 * eval.c (error_trace): Show location of the form being expanded in the "during expansion" message, rather than, confusingly, the locaton of the code of its macro. Then, if the location of the macro is available, show that in a separate message whose wording makes it clear that the location of the expanding macro is being given.
* Support simple list arguments in getopts.Kaz Kylheku2016-11-032-10/+40
| | | | | | | | | | | | | | | | | * share/txr/stdlib/getopts.tl (defstruct sys:opt-parsed): New slot eff-type, appearing as an optional parameter in the boa constructor parameter list. (opt-desc check): Allow a type to be a cons with list in the car position. (sys:opt-parsed convert-type): Use the eff-type slot if it is set instead of the type from the descriptor. This lets us override the type for a slot, which is key to the recursive approach to how lists are handled in this same function. (opthelp): Show list type options in a visual way which suggests the use. No details are given. * txr.1: Documented list option type.
* Introducing command line option processing system.Kaz Kylheku2016-11-033-0/+725
| | | | | | | | | | | * lisplib.c (getopts_set_entries, getopts_instantiate): New functions. (lisplib_init): Register auto-loading for getopt.tl via new functions. * share/txr/stdlib/getopts.tl: New file. * txr.1: Documented new library area.
* New negated equality test functions.Kaz Kylheku2016-11-013-1/+54
| | | | | | | | | * 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
* Circ print: fix recursion from print methods.Kaz Kylheku2016-11-014-12/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two issues addressed here, both occurring when *print-circle* is enabled and an object has struct components which have a custom print method that re-enters the object printer. One issue is that the children of these components which occur just once print with spurious labels: like #3=, when no matching #3# occurs. The other bug is a wrong "unexpected duplicate object" exception caused by mismanagement of the child object's label hash table and its merging with the parent. * stream.h (struct stream_ctx): New member, obj_hash_prev. Makes the parent hash table known to populate_obj_hash, if there is a table, otherwise nil. * lib.c (populate_obj_hash): If there is a parent table, check each object in it. If it occurs, then bail. I.e. don't add objects to the child table which occur in the parent. This fixes both issues. Also, we do the unexpected duplicate object check right here now: if we traverse an object that already printed without a label (because it is not known to be duplicate), that means that a custom print method is inappropriately introducing new references to existing objects, contrary to the rules. (obj_hash_merge): The logic here is now simplified. All entries in the child table are simply moved to the parent. If anything already exists, that is an unexpected stuation indicating an internal problem, turned into a variant of the unexpected duplicate object message. * tests/012/circ.tl: New file, giving tests for the bugs. * tests/012/circ.expected: New file.
* Flush *stdout* upon unhandled exception.Kaz Kylheku2016-10-311-0/+1
| | | | | | | | * unwind.c (uw_unwind_to_exit_point): Prior to printing diagnostics related to an unhandled exception to std_error, flush std_output. This clarifies the output in situations when both std_error and std_output go to the same destination, and the exception occurred while producing output on std_output.
* Don't enter symbols into cycle-identifying hash.Kaz Kylheku2016-10-311-2/+7
| | | | | | | | | * lib.c (circle_print_eligible): New inline function. (obj_print_impl): Do not bother with hash lookup for interned objects that don't participate in circle notation. (populate_obj_hash): Replace open-coded test with call to circle_print_eligible.
* Use obj_print_impl for printing hash contents.Kaz Kylheku2016-10-311-12/+18
| | | | | | | | | | | | | * hash.c (print_key_val): Static function removed. (hash_print_op): Don't use maphash over print_key_val to print hash tables. Use open-coded iteration and printing with calls to obj_print_impl. This was occassioned by a bug in circle printing. The use of obj_print by hash_print_op resembles the actions of a custom print method on a structure. A bug showed up which is masked by refactoring to more direct recursion via obj_print_impl. (The bug still has to be fixed, though).
* Relax restrictions on dwim places.Kaz Kylheku2016-10-315-46/+107
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-306-53/+209
| | | | | | | | | | | | | | | | | | | | | | | | * 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-293-11/+56
| | | | | | | | | | | | | | | | | | * 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-293-0/+128
| | | | | | | | | | | | | 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-282-2/+196
| | | | | | | | | | | | | | * 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.
* dwim place: multiple accesses, eval order.Kaz Kylheku2016-10-271-19/+18
| | | | | | | | | | | | | * share/txr/stdlib/place.tl (defplace dwim): In updater, removing unused and redundant gensyms. Engaging unused oldval-sym as a temporary to hold the result of invoking (,ogetter-sym), the "getter" for the sequence object place we are operating on. Both references then refer to this resut instead of expanding the getter twice. Though getters should not have side effects, they could be expensive. In simple setter and deleter, setting up obj-sym similarly. We don't make multiple accesses to the sequence, but we were evaluating it in the wrong order w.r.t the index and new-val.
* Fix unbound variable in seq place update.Kaz Kylheku2016-10-261-2/+2
| | | | | | * share/txr/stdlib/place.tl (defplace sub): Fix unbound variable seq-setter in update expander. Wrong unquoting level.
* Improve alet macro.Kaz Kylheku2016-10-262-20/+23
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Same fix in tok-where as tok-str.Kaz Kylheku2016-10-261-1/+23
| | | | | | | | lib.c (tok_where) Implement new loop which suppresses empty tokens immediately matching after non-empty tokens. Old loop available under compatibility. No documentation update needed since tok-where is already documented as working like tok-str.
* Don't bother with numeq comparison in tok_where.Kaz Kylheku2016-10-261-1/+1
| | | | * lib.c (tok_where): Just compare match_end == match_start.
* Fix regression: broken tok_where.Kaz Kylheku2016-10-261-7/+10
| | | | | | * lib.c (tok_where): Check that the regex match succeeded before destructuring the result with range_bind.
* Fix tok-str semantics once again.Kaz Kylheku2016-10-263-20/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* obj_print: uw guard frame only when circ printing.Kaz Kylheku2016-10-261-2/+4
| | | | | | * lib.c (obj_print): Only set up and tear down the continuation-blocking unwind frame when doing circle printing.
* Let guard frames optionally pass through unwinding.Kaz Kylheku2016-10-265-5/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | We have a bug in that when an exception occurs in a context called from obj_print, the guard for stopping continuation captures across obj_print also unintentially blocks the unwinding. Let's make the unwinding blockage optional * unwind.c (uw_unwind_to_exit_point): If a UW_GUARD is encountered, do not abort if the uw_ok flag is set; keep unwinding. (uw_push_guard): New uw_ok argument, initializes the uw_ok member of a guard frame. * unwind.h (struct uw_guard): New struct type. (union uw_frame): New member gu of type struct uw_guard. (uw_push_guard): Declaration updated. * ftw.c (ftw_callback): Pass zero as new uw_push_guard argument: no unwinding across the POSIX library function ftw. * glob.c (errfunc_thunk): Likewise, no unwinding across the library function glob. * lib.c (obj_print): Pass 1 as new uw_push_guard argument: continuations can't be captured, but unwinding is okay.
* last, butlast: become accessors, get optional arg.Kaz Kylheku2016-10-265-56/+158
| | | | | | | | | | | | | | | | | | | | * 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-262-3/+69
| | | | | | * share/txr/stdlib/place.tl (defplace sub): New place. * txr.1: Document sub as accessor.
* New accessors nthlast and butlastn.Kaz Kylheku2016-10-255-0/+239
| | | | | | | | | | | | | | * 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.
* nthcdr place bugfix: wrong return value.Kaz Kylheku2016-10-251-1/+1
| | | | | | * share/txr/stdlib/place.tl (defplace nthcdr): In the case when list is a place, the setter operation returns the wrong value: the entire list, rather than the value assigned.
* 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.
* Don't expand macros in quasiquote expander.Kaz Kylheku2016-10-241-27/+24
| | | | | | | | | | | | | | | The quasiquote expander does something very odd: it passes the macro-time environment through its recursion and calls expand on some forms. Why was this done? Perhaps it helps promote certain optimizations. In any case, it gets in the way of being able to expand quasiquotes in a non-macro context. * eval.c (expand_qquote_rec): Lose menv argument, and eliminate all expand calls. (expand_qquote): Lose menv argument, and don't pass it down to expand_qquote_rec. (me_qquote): Ignore menv argument; don't pass it down to expand_qquote.
* hash-construct: eliminate redundant intern.Kaz Kylheku2016-10-241-1/+1
| | | | | | * hash.c (hash_init): register hash-constrct using symbol in hash_construct_s variable that was previously interned rather than result of new call to intern.
* Fix non-working quasiquote over struct literals.Kaz Kylheku2016-10-244-7/+11
| | | | | | | | | | | | | | | | | | | | Turns out that there is missing support for quasiquoting over structs. Code analogous to the way vector and hash literals are handled is missing for structs. * eval.c (expand_qquote_rec): Handle struct_lit_s forms specially, like hash_lit_s and vector_lit_s. commit 1e5bc5708d5763f20a7774f9348e825304a51adc * struct.c (make_struct_lit_s): New symbol variable. (struct_init): Store interned sys:make-struct-lit symbol into make_struct_lit_s, and use that to register the function. * struct.h (make_struct_lit_s): Declared. * tests/012/struct.tl: Update struct literal quasiquote test cases to reflect fixed behavior.
* doc: missing plurals in headings, missing .desc.Kaz Kylheku2016-10-232-3/+8
| | | | | | | | * 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-232-1/+19
| | | | | | | * 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-216-724/+757
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* struct bug: mismanagement of static slot store.Kaz Kylheku2016-10-211-1/+4
| | | | | | | | | | | | | | | | | The bug_unless statement was found to go off, indicating an internal problem. Indeed, the store of inherited static slots were being set to non-nil by incorrect copying in two places. This is harmless in and of itself; it's just a way of being tidy. If a slot's value is located elsewhere, then the local store must be nil. * struct.c (static_slot_home_fixup): After fetching a fresh copy of the home type's stslot entry, clear the store to nil. (make_struct_type): Likewise. (struct_type_mark): Use assert for this rather than bug_unless, because it happens in the middle of garbage collection. Throwing an exception out of the middle of gc is a nonstarter.
* Document circular printing.Kaz Kylheku2016-10-211-0/+144
| | | | | * txr.1: Documenting circular notation and the *print-circle* variable.
* Block continuation capture across printer.Kaz Kylheku2016-10-211-0/+5
| | | | | * lib.c (obj_print): Applying a continuation guard around the body of the function. This seems prudent.
* repl: don't send error trace to *stderr*.Kaz Kylheku2016-10-211-1/+1
| | | | | | | * parser.c (repl): Pass out_stream rather than std_error to error_trace. I don't remember the original intent here. All it does is create strange puzzling behavior when an error occurs in the middle of a line of output that isn't flushed yet.
* Another fix to print method circular printing.Kaz Kylheku2016-10-211-8/+21
| | | | | | | | | | | | | | | | | | | | | | | Continuing on the theme of the previous patch, we now properly detect the situation when the recursive call is re-introducing duplicate references to objects that have already been sent to the stream without at #<num>= label. It's too late to print those objects, so we throw an exception. * lib.c (obj_print_impl): When we print an object that doesn't have duplicates (its hash entry has a nil value), we replace that value with the : symbol to indicate that the object has already been printed. (obj_hash_merge): New function, factoring out the hash merging logic from obj_print, introduced in parent commit. Here, we detect the case that the recursive print call has submitted to us an object which was already printed without a label: because it is associated with the : symbol in the parent hash. This situation is a show-stopper so we throw. We cannot attempt to print the object in any manner because we can get into runaway recursion. (obj_print): Hash merging logic replaced with call to new static function.
* Fix circular printing across print methods.Kaz Kylheku2016-10-211-0/+10
| | | | | | | | | * lib.c (obj_print): When invoked recursively in circular printing mode, collect the nodes of the new object into a separate hash table. Then merge these entries into to the previous hash table. If the newly visited object visits objects we have already seen, suppress those entries.