summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* new function: nthKaz Kylheku2017-07-185-0/+44
| | | | | | | | | | | | | | | | Just the ANSI CL nth for lists. * eval.c (eval_init): Register nth intrinsic. * lib.c (nth): New function. * lib.h (nth): Declared. * share/txr/stdlib/place.tl (nth): New place macro, trivially takes care of making nth an accessor. Place macros are terrific! * txr.1: Documented.
* new function: path-catKaz Kylheku2017-07-183-0/+125
| | | | | | | | | * stream.c (path_cat): New function. (stream_init): Registered path_cat. * stream.h (path_cat): Declared. * txr.1: Documented.
* remove-path: exception semantics adjusted.Kaz Kylheku2017-07-172-8/+14
| | | | | | | | | | | | * stream.c (remove_path): The second argument now defaults to false rather than true, and controls only whether an exception is thrown in the non-existence case. Thus, the function throws errors by default, as before, but doesn't throw by default if the failure reason is that the path doesn't exist. Previously it threw by default in all situations, and the flag turned all errors into a nil return. * txr.1: Documented.
* lib: new function, relate.Kaz Kylheku2017-07-174-0/+85
| | | | | | | | | | | * eval.c (eval_init): Register new intrinsic relate. * lib.c (do_relate, do_relate_dfl): New static functions. (relate): New function. * lib.h (relate): Declared. * txr.1: Documented.
* getopts: New argument type :text.Kaz Kylheku2017-07-162-2/+8
| | | | | | | | | | * share/txr/stdlib/getopts.tl (opt-desc): New entry in valid-types, :text symbol. (sys:opt-parsed convert-type): Handle :text case. This is a no-op since :text applied no treatment. (opthelp): Provide help text for :text type. * txr.1: Documented :text getopts option type.
* getopts: Fix broken custom function option type.Kaz Kylheku2017-07-161-2/+2
| | | | | | This was broken on 2016-11-03 by the commit "Support simple list arguments in getopts." The sys:opt-parsed type has no type slot.
* ffi: add offset argument to ffi buffer functions.Kaz Kylheku2017-07-163-34/+72
| | | | | | | | | | | | | * ffi.c (ffi_put_into, ffi_in, ffi_get, ffi_out): New offset parameter. (ffi_init): Re-register ffi-put-into, ffi-in, ffi-get and ffi-out with new optional parameter. * ffi.c (ffi_put_into, ffi_in, ffi_get, ffi_out): Declarations updated. * txr.1: Documented new argument on ffi-put-into, ffi-in and ffi-get. The documentation for ffi-out doesn't exist!
* regex: don't print superfluous parens around classes.Kaz Kylheku2017-07-161-2/+2
| | | | | | | | * regex.c (print_rec): Switching from negative tests to positive: print parens around elements of a compound which have a lower precedence. The previously incorrectly omitted set and cset remain unmentioned, so under this inversion of logic, they print without parentheses.
* format: support leading zero printing for floats.Kaz Kylheku2017-07-162-3/+16
| | | | | | | | | | | | | | | For a floating-point argument, the following behavior is supported by the ~a, ~s and ~f format directives: if the precision has a leading zero, then leading zeros are added, up to one less than the field width. * stream.c (formatv): Set the precision to one less than the field width when rendering floats, rather than to zero. The output_num code takes the precision as the cue for padding zeros. * txr.1: Updated format documentation, and clarified a few things also.
* global environment accessors can now create bindings.Kaz Kylheku2017-07-162-22/+18
| | | | | | | | | | | | | | The accessors symbol-value, symbol-function and symbol-macro can now be used to store a value to nonexistent bindings, which brings those bindings into existence. * share/txr/stdlib/place.tl (sys:ge-fun-getter-setter, sys:get-vb): Don't throw exceptions for nonexistent binding lookups: create and return the bindings instead. For methods, use static-slot-ensure rather than static-slot-set. Thus new methods can be defined by setting to a (meth ...) place. * txr.1: Doc updated.
* bugfix: pattern language undefined warning system.Kaz Kylheku2017-07-161-2/+3
| | | | | | | | * match.c (match_reg_var): The uw_tentative_def_exists check is being made against a symbol rather than the tag. This check will always fail. There is no ill consequence. Just that uw_register_tentative_def will be called redundantly when it doesn't have to be.
* trace: allow format and * functions to be traced.Kaz Kylheku2017-07-161-2/+5
| | | | | | | | * share/txr/stdlib/trace.tl (sys:tr*, sys:trfm): New variables, holding the * and format functions. (sys:trace-enter, sys:trace-leave): Use format and * through the aliases, so we don't trigger infinite recursion if these are traced.
* carray: add offset to carray-buf.Kaz Kylheku2017-07-153-21/+61
| | | | | | | | | | | | | | * ffi.c (struct carray): New member, offs. (make_carray): Initiialize offs member from new argument. (copy_carray, carray_blank, carry_ptr, carray_sub, carray_pun, carray_unum, carray_num): Pass zero offset to (carray_buf): New optional parameter off_in. (carray_buf_sync): Handle offset. (ffi_init): Update registration of carray-buf. * ffi.h (make_carray, carray_buf): Declaration updated. * txr.1: Documented.
* Fix use of raw null constant in carray implementation.Kaz Kylheku2017-07-151-1/+1
| | | | | | * ffi.c (carray_cptr): Ref argument in make_carray call should be specified as nil not 0. The meaning is the same, but it's wrong style for TXR internals.
* Remove unused variable in placelet implementation.Kaz Kylheku2017-07-151-1/+1
| | | | | * share/txr/stdlib/place.tl (sys:placelet-1): Remove the genyms called steal-getter which is not referenced.
* bugfix: spurious warnings issued against lisp1 eval.Kaz Kylheku2017-07-141-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Repro test cases for this: A: (progn (defun f ()) [f]). This emits a warning against the [f] usage, even though there is a tentative definition of f as a function. B: (progn (defun g () [f]) (defun f ())). Emits a warning against [f] usage which is not purged by the evaluation of the later definition. Both problems are related to the separation of deferred warnings into the tag namespaces: symbols and functions. When [f] is being expanded, the deferred warning is put into the variable namespace. So it doesn't match a tentative def in the function namespace which would otherwise suppress it. A subsequent function definition only purges the warning for the function space. We introduce a third space, the "symbol space". Lisp-1 deferred warnings are introduced against this namespace and both variable and function definitions purge deferred warnings from that namespace also, in addition to their respective proper namespace. This solves problem B. Problem A is solved by checking, when [f] is expanded, for tentative definitions of f in both the variable and function tag space. Note that test case B still warns when entered into the listener, because the listener dumps deferred warnings prior to evaluation, thus prior to evaluating (defun f ()). * eval.c (op_defvarl, op_defun): Purge deferred warnings from the sym tag namespace also. (expand_lisp1): Do not emit the deferred warning for a nonexistent name if it has a tentative definition either as a function or variable. When emitting the deferred warning, use the sym namespace.
* New :lists feature in @(collect)/@(coll).Kaz Kylheku2017-07-113-6/+47
| | | | | | | | | | | | | | | | | | | This is for those situations when multiple lists are being collected, and must all be bound even if empty. Yet, the lists are independent rather than parallel, so the discipline of :vars is too rigid. * match.c (lists_k): New keyword symbol variable. (h_coll, v_collect): Extract :lists argument as local variable lists, validate that :lists is not used on @(repeat)/@(rep) and implement logic. (match_expand_keyword_args): Treat expansion of :lists the same way as :vars. (syms_init): Initialize lists_k. * match.c (lists_k): Declared. * txr.1: Documented.
* doc: :vars not vars.Kaz Kylheku2017-07-111-3/+6
| | | | | * txr.1: Fix text under gather and collect directive wrongly referring to :vars keyword as just vars in the plain font.
* txr-embeded-arg utility: use FFI types and buffers.Kaz Kylheku2017-07-101-10/+7
| | | | | | | | * txr-embedded-arg.txr: Streamline the logic by using buffers and the FFI type (zarray 128 char) which converts between a null terminated buffer of 128 UTF-8 characters and a string. We get not only null termination, as before, but clean padding ith zeros up to the size of the 128 byte area.
* Version 182.txr-182Kaz Kylheku2017-07-097-544/+588
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* doc: fix structure of section on compatibility.Kaz Kylheku2017-07-091-4/+4
| | | | | | * txr.1: the sections following the Overview were wrongly subordinated to Overview. They are now on the same level.
* ffi: new function, zero-fill.Kaz Kylheku2017-07-093-1/+67
| | | | | | | | | * ffi.c (zero_fill): New function. (ffi_init): zero-fill intrinsic registered. * ffi.h (zero_fill): Declared. * txr.1: Documented.
* places: remove superfluous @1.Kaz Kylheku2017-07-091-2/+2
| | | | | | * share/txr/stdlib/place.tl (sys:get:fun-getter-setter): Remove superfluous @1 from op macro syntax, on the basis that (op function @1) is equivalent to (op function).
* structs: improve access to initfun and postinitfun.Kaz Kylheku2017-07-096-7/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In this change, a struct type's initfun and postinitfun become mutable. This is achieved by modeling them as the pseudo-static-slots :initfun and :postinitfun. Effectively these now behave as reserved names which do not denote static slots but these special functions. * eval.c (lookup_fun): When (meth type slot) syntax is encountered, treat the slot names :init and :postinit specially: retrieve these special functions instead of accessing static slots. * share/txr/stdlib/place.tl (sys:get-fun-getter-setter): Similarly, when handling (meth type slot) syntax, return the alternative getter/setter functions for the special functions, not the static slot accessing functions. Also, getting rid of a useless @1 here in existing code, since (op foo @1) is equivalent to (op foo). * share/txr/stdlib/struct.tl (sys:defmeth): Check for the special names :init and :postinit, handling these through the appropriate setter functions rather than static-slot-ensure. * struct.c (init_k, postinit_k): New keyword symbol variables. (struct_init): Initialize init_k and postinit_k. Register intrinsics struct-get-initfun, struct-set-initfun, struct-get-postinitfun and struct-set-postinitfun. * (struct_get_initfun, struct_set_initfun, struct_get_postinitfun, struct_set_postinitfun): New functions. (method_name): For each struct type visited, check whether the function is the initfun or postinitfun and return the appropriate meth syntax if so. * struct.h (init_k, postinit_k, struct_get_initfun, struct_set_initfun, struct_get_postinitfun, struct_set_postinitfun): Declared. * txr.1: Documented. Updated description of method-name, defmeth, and documented new functions.
* doc: missing word in compat note 165.Kaz Kylheku2017-07-091-1/+1
| | | | * txr.1: The word was "change" is missing in the sentence.
* doc: fix compat note 156.Kaz Kylheku2017-07-091-5/+14
| | | | | | | | | | * txr.1: Fix a flaw in the compat note 156 wording. The workaround described only applies to TXR that has not been upgraded to 157 or newer; it is not an alternative to using the compat option, but a way to fix code under old TXR. Also adding here the recommendation that applications should switch to the new evaluating case functions rather than relying on the compat switch.
* linenoise: replace linefeeds with CR in previous result.Kaz Kylheku2017-07-092-1/+3
| | | | | | | | | | | | | | This fixes the issue that when a multi-line result is pasted into the edit buffer with Ctrl-X P, the line breaks appear in it as linefeeds, displayed as ^J. In linenoise, we need line breaks to be carriage returns. * linenoise/linenoise.c (lino_set_result): replace newlines with carriage returns in the given string. * linenoise/linenoise.h (lino_set_result): Add comment that function takes ownership of memory assumed to be malloced, and that it modifies it.
* doc: make-struct-type postinitfun: outdated text.Kaz Kylheku2017-07-091-9/+11
| | | | | | | | * txr.1: Replace description of make-struct-type's postinitfun argument which was still claiming that the calls are in opposite order relative to initfun calls. That changed after TXR 148 but was documented only for defstruct. Also updating the compat note for 148.
* doc: bad formatting in make-struct-typeKaz Kylheku2017-07-091-1/+1
| | | | | * txr.1: Remove spurious parenthesis in syntax synopsis of make-struct-type.
* doc: fixes under window-map.Kaz Kylheku2017-07-081-2/+2
| | | | | * txr.1: grammar fix: S-V number agreement. Add missing number 2.
* doc: fix spurious trailing comma in heading.Kaz Kylheku2017-07-081-1/+1
| | | | | * txr.1: Fix "FFI types short ... long, ulong," to "FFI types short ... long and ulong".
* doc: fix inappropriate code/codn in FFI types.Kaz Kylheku2017-07-081-6/+6
| | | | | * txr.1: In some parametrized type descriptions, a parameter is typeset using .code or .codn rather than .meta or metn.
* doc: put [+]/[-] open/collapse markers on right.Kaz Kylheku2017-07-081-3/+3
| | | | | | | * genman.txr (closedtxt, opentxt): Add leading space. In TOC filtering code, insert the toggle elements just before the closing </dt> rather than before opening <a>.
* doc: C and POSIX types, sections with heading.Kaz Kylheku2017-07-081-31/+9
| | | | | | * txr.1: the additional types are given proper headings so the identifiers are cross referenced and appear in the TOC.
* doc: change Buffers heading.Kaz Kylheku2017-07-081-4/+9
| | | | | | * txr.1: This change to the buffers heading causes the buf identifier to be cross-referenced, which is useful to people browsing the FFI section. Fixing some wording too.
* doc: merge redundant sections on cptr.Kaz Kylheku2017-07-081-33/+28
| | | | | * txr.1: The FFI cptr type is described in two separate sections. These are merged and duplication removed.
* doc: subdivide FFI-related functionsKaz Kylheku2017-07-081-1/+33
| | | | | * txr.1: The functions and macros in FFI are divided into logical groups with own section headings.
* doc: FFI restructured.Kaz Kylheku2017-07-071-57/+140
| | | | | | | | PDF page count hits 600! * txr.1: FFI becomes a major SH section. The FFI types become separate numbered paragraphs with headings. Parametrized types look function-like with Syntax headings.
* expander: fix neglect to expand lambda and fun.Kaz Kylheku2017-07-071-4/+15
| | | | | | | | | | | | | Now that lambda expressions are supported as function names in the first position of a compound expression and as an argument to the fun operator, it will greatly behoove us if we expand them properly. Then tests/012/quine.tl will pass. * eval.c (do_expand): Handle fun specially. If the argument is a lambda expression, then expand that and generate an expanded fun form, otherwise just yield form. When expanding function calls, check whether the first argument is a lambda and expand it.
* tests: add lambda quine tests.Kaz Kylheku2017-07-072-0/+17
| | | | | | | | The tests fail as of this commit. * tests/012/quine.expected: New file. * tests/012/quine.tl: New file.
* doc: fun operator has way to see macros.Kaz Kylheku2017-07-071-1/+11
| | | | | | * txr.1: Clarify an otherwise misleading text. It's true that the fun operator doesn't resolve macros via straight symbol names, but it does do so via (macro <name>) syntax.
* doc: document function names in compound forms.Kaz Kylheku2017-07-071-0/+4
| | | | | * txr.1: Under Compound Forms, specify what is a function name.
* Lisp: lambda expressions are function names now.Kaz Kylheku2017-07-072-8/+25
| | | | | | | | | | | | | | | | | | | * eval.c (lookup_fun): With this two-liner change, the forms ((lambda (x) x) 42) and (fun (lambda ())) just work. This is not just compatibility with other dialects; it is necessary for consistency with func-get-name, which already returns lambda expressions, effectively asserting that they are function names. * txr.1: Fix documentation for fun operator. The Dialect Note saying that a lambda expression is not a function name in TXR Lisp is removed. Document that function names may be any of those produced by func-get-name. This has already been true for macros and methods, just not for lambda expressions. Under fun-get-name, document that lambda expressions are produced for interpreted functions not found in any binding by the previous searches.
* doc: mention syntax for calling methods.Kaz Kylheku2017-07-071-2/+21
| | | | | | * txr.1: The recommendation to use call-super-fun is rounded out by mentioning that the (meth ...) syntax can achieve the same thing. An example of it is added under call-super-fun.
* doc: fix call-super-fun error and add example.Kaz Kylheku2017-07-071-1/+23
| | | | | | * txr.1: call-super-fun method intro paragraph wrongly refers to call-super-method. Adding example about how to call a base class method.
* doc: deprecate call-super-method.Kaz Kylheku2017-07-071-1/+16
| | | | | | | * txr.1: Recommend call-super-fun for calling a base class method. Mark call-super-method deprecated, and add a Note about why it's not correct to use it for the purpose of calling a base method.
* structs: tighten call-super-fun behavior.Kaz Kylheku2017-07-071-3/+5
| | | | | | | | * struct.c (call_super_fun): Do not allow type to be a struct instance, which is a consequence of the super function being used. The documentation says that the argument is a type and mentions no possibility of it being an instance. Allowing a struct invites mistakes.
* structs: get tests/012/stslot.tl to pass.Kaz Kylheku2017-07-051-10/+7
| | | | | | | | | | | | | | | * struct.c (static_slot_rewrite_rec): A simple rearrangement: switch to postorder traversal, doing the derived structs first, then this struct. Why does this fix a bug? Because when the assignment *s = *to occurs for the node at the root of the recursion, s and from point to the same object. And so the assignment alters from, which is the search key. When the children are then processed, the search key doesn't match anything: it now looks like the to slot that the children are supposed to get, and so they don't have it, of course. So in other words the slot being rewritten is not found in the derived types and not rewritten there as it should be.
* structs: new tests for static-slot-ensure.Kaz Kylheku2017-07-052-0/+23
| | | | | | * tests/012/stslot.expected: New file. * tests/012/stslot.tl: New file. b/tests/012/stslot.tl
* structs: bugfix in static-slot-ensure.Kaz Kylheku2017-07-051-1/+1
| | | | | | | | | | | | | | | | * struct.c (static_sot_ens_rec): This change is in the case when a static slot is being ensured in a struct type which already has that static slot by inheritance. In that situation, the inheritance is severed and the struct gets its own non-inherited slot of that name. Then all of the derived structs are scanned. If any contain the original inherited slot, it is updated to the new, non-inherited one. The bug here is that we were copying the home_offs field of the original inherited slot to the new one! This is wrong; the new slot is not related to the original inherited one. The new slot is a home slot and its own offset must be home_offs. We can calculate that simply as its delta from the static slot table base.