summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* doc: reorder typedef and deffi-cb sections.Kaz Kylheku2017-05-201-21/+21
| | | | | * txr.1: typedef moved below deffi-cb, so it it is together with sizeof.
* ffi: overhaul ffi-call API and document it.Kaz Kylheku2017-05-201-0/+47
| | | | | | | | | | | | | | | * ffi.c (ffi_call_wrap): Take struct args * parameters rather than a list. Check that number of arguments matches required number from call desc. No need to build argument array any more; we just refer to the one in args. Also, the first two parameters are reversed for consistency with other functions. (ffi_init): Update registration of ffi-call to reflect type change. * ffi.h (ffi_call_wrap): Declaration updated. * txr.1: Documented ffi-call.
* ffi: turn carray-ref into accessor.Kaz Kylheku2017-05-201-1/+8
| | | | | | | | | | * lisplib.c (ffi_set_entries): Add carray-ref to list of autoload names. * share/txr/stdlib/ffi.tl (carray-ref, carray-refset): Registered function pair as a simple accessor. * txr.1: Updated carray-ref doc.
* ffi: variable length zarray needs in operation.Kaz Kylheku2017-05-201-1/+13
| | | | | | | | * ffi.c (ffi_varray_null_term_in): New static function. (ffi_type_compile): Wire in new function as in operation of variable length zarray. * txr.1: Documented.
* ffi: new carray-buf-sync function.Kaz Kylheku2017-05-201-0/+27
| | | | | | | | | * ffi.c (carray_buf_sync): New function. (ffi_init): carray-buf-sync intrinsic registered. * ffi.h (carray_buf_sync): Declared. * txr.1: Documented.
* ffi: new function, carray-cptr.Kaz Kylheku2017-05-191-0/+41
| | | | | | | | | * ffi.c (carray_cptr): New function. (ffi_init): Registered intrinsic. * ffi.h (carray_cptr): Declared. * txr.1: Documented.
* doc: update variable array desription.Kaz Kylheku2017-05-191-7/+26
| | | | | | | * txr.1: Fix misleading text which says that variable arrays correspond to pointers. They do not; they must be wrapped in expicit (ptr ...). Also documenting new get operation of variable zarray.
* awk: new feature: again operator.Kaz Kylheku2017-05-191-0/+25
| | | | | | | | | | | | | * share/txr/stdlib/awk.tl (sys:awk-state loop): Wrap a loop around around the two forms that split the record into fields and dispatch the main rule function. The loop repeats if the named block returns :awk-again. (sys:awk-mac-let): New local macro (again) which bails out of the :awk-rec block just like (next) does, but specifies :awk-again as the return value. * txr.1: Documented.
* doc: ffi carray type and carray objects documented.Kaz Kylheku2017-05-181-35/+556
| | | | * txr.1: Documented the total current state of carray.
* ffi: bugfix: broken buf in semantics, bad doc.Kaz Kylheku2017-05-181-20/+74
| | | | | | | | | | | | | * ffi.c (ffi_buf_in): The bug in this one is that if *loc has been mutated to a null pointer, we want to produce a nil, rather than to try to duplicate the buffer. (ffi_buf_d_in): The bug here is that *loc is always different from origptr, because origptr is from the original buffer object, whereas we placed a copy of it into *loc. The semantics is changed. We take ownership of whatever pointer is there. If it is null, then yield nil. * txr.1: buf and buf-d documentation revised.
* ffi: macro named ffi for type compiling shorthand.Kaz Kylheku2017-05-171-0/+15
| | | | | | | | | * lisplib.c (ffi_set_entries): Add "ffi" to autoload name list. * share/txr/stdlib/ffi.tl (ffi): New macro. * txr.1: Documented.
* ffi: typedef macro instead of deffi-type.Kaz Kylheku2017-05-171-8/+6
| | | | | | | | | | * share/txr/stdlib/ffi.tl (typedef): New macro. * lisplib.c (ffi_set_entries): Add typedef to autoload name list. * txr.1: Doc update. Remove mentions of deffi-type, though it continues to work.
* Version 175.txr-175Kaz Kylheku2017-05-151-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* ffi: use dynamic allocation for wstr and wstr-d.Kaz Kylheku2017-05-131-26/+3
| | | | | | | | | | | | | | | | | | | The direct pointer use of the wstr type causes problems for callbacks. Plus allowing the foreign world to retain the pointers into string objects is inherenty unsafe. We can introduce an "unsafe wstr" type in a later release for efficiency. * ffi.c (ffi_wstr_in): New function. (ffi_wstr_put): Removed by ffi_wstr_d_put rename. (ffi_wstr_d_put): Renamed to ffi_wstr_put: both wstr and wstr-d strings have a dynamically-allocating put. (ffi_init_types): Give wstr type ffi_wstr_in handler. wstr-d type's registration switched to ffi_wstr_put, which is just ffi_wstr_d_put renamed. * txr.1: Memory management notes for wstr updated.
* ffi: support programmable abort return value.Kaz Kylheku2017-05-111-5/+27
| | | | | | | | | | | | | | | | | | | | | | | | | * ffi.c (stuct txr_ffi_closure): New member, abort_retval. (ffi_closure_mark_op): Mark the new member. (ffi_closure_dispatch_safe): Implement the abort_retval. If it is not nil, use put to place the value into the return buffer. There is a risk that this could also throw an exception, which is no longer protected: programer's problem. (ffi_make_closure): New abort_ret_in argument, which is defaulted and stored. (ffi_init): Update registration of ffi-make-closure to reflect new argument. * ffi.h (ffi_make_closure): Declaration updated. * share/txr/stdlib/ffi.tl (sys:deffi-cb-expander): Add abort-retval parameter; insert into ffi-make-closure call. (deffi-cb): Take optional abort-retval expression; pass it down to the expander function. (deffi-cb-unsafe): Pass nil as abort-retval down to expander. * txr.1: Documented.
* ffi: a measure of safety for callbacks.Kaz Kylheku2017-05-111-5/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't want, by default, for callbacks to capture delimited continuations across foreign code, or perpetrate non-local transfers across foreign code. Here, we take an approach similar for what was done in ftw_wrap. * ffi.c (s_exit_point): New global variable with internal linkage. (ffi_call_wrap): If s_exit_point isn't nil, then it means that the callback intercepted a nonlocal transfer and stored its exit point. We resume the transfer to that exit point instead of returning normally. (ffi_closure_dispatch_safe): New static function. (ffi_make_closure): Support a new argument which indicates whether to make a closure which uses ffi_closure_dispatch_safe, or ffi_closure_dispatch. (ffi_init): Update registration of ffi-make-closure intrinsic. * ffi.h (ffi_make_closure): Declaration updated. * share/txr/stdlib/ffi.tl (sys:deffi-cb-expander): New function. (deffi-cb): Macro internals replaced by call to new function. (deffi-cb-safe): New macro. * txr.1: Documentation of ffi-make-closure updated. New deffi-cb-unsafe macro documented.
* ffi: adjust semantics of zarray of characters.Kaz Kylheku2017-05-101-4/+26
| | | | | | | | | | | | | We want to be able to extract null-terminated UTF-8 strings from arrays, without trailing junk, yet retain the ability to extract the entire array including embedded nulls. The natural way is to use the array/zarray distinction. * ffi.c (ffi_array_in, ffi_array_get): Don't try to guess whether the array is null terminated; just rely on the null_term flag, and treat accordingly. * txr.1: Doc updated.
* doc: cptr.Kaz Kylheku2017-05-101-0/+149
| | | | * txr.1: The cptr type is now documented.
* doc: relocate and rewrite buffer literal description.Kaz Kylheku2017-05-091-12/+25
| | | | | | * txr.1: Buffer literals are now described much earlier in the document under Additional Syntax rather than in the Buffers section.
* doc: add buf and cptr to type diagram.Kaz Kylheku2017-05-091-1/+5
| | | | * txr.1: Update ASCII diagram in Object Types section.
* doc: dlopen added.Kaz Kylheku2017-05-091-0/+166
| | | | | * txr.1: Documented dlopen, dlclose and friends, plus the rtld-* variables.
* ffi: integers and chars may convert to C float.Kaz Kylheku2017-05-091-3/+3
| | | | | | | | | * ffi.c (ffi_float_put, ffi_double_put): Support a useful type looseness by allowing integers and character Lisp values to pair with FFI floating-point types, imitating the conversion which happens in C function calls. * txr.1: Updated.
* doc: FFI module documented.Kaz Kylheku2017-05-091-0/+1618
|
* doc: documenting buffers.Kaz Kylheku2017-05-081-0/+739
|
* bugfix: tostringp not behaving right for floats.Kaz Kylheku2017-05-041-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | The obj printer is ignoring the pretty flag when rendering floating-point numbers, and just formatting them using *print-flo-format*. To address this issue, we introduce an additional *pprint-flo-format* variable. * lib.c (obj_print_impl): In the FLNUM case, use either the value of *print-flo-format* or *pprint-flo-format* based on the value of the pretty flag. * stream.c (pprint_flo_format_s): New symbol variable. (stream_init): Initialize pprint_flo_format_s with interned symbol *pprint-flo-format* and register this as a special variable. * stream.c (pprint_flo_format_s): Declared. * txr.1: Documented *pprint-flo-format*. Also put in a note in the description of the various print functions that the equivalences based on ~s and ~a only apply to floats when the special variables have their original values.
* doc: clarify when exit points are torn down.Kaz Kylheku2017-05-041-0/+11
| | | | | | * txr.1: Adding a paragraph under unwind-protect clarifying that exit points are removed during unwinding, not during the search for an exit point.
* New path slot in stat struct.Kaz Kylheku2017-04-081-2/+24
| | | | | | | | | | | | | | | | | | | | | | | | * ftw.c (ftw_callback): Pass path to stat_to_struct function. * socket.c (path_s): Variable definition removed from here. (sock_load_init): Do not intern path symbol here. * sysif.c (path_s): Variable definition moved here. (stat_to_struct): New parameter, path. Store its argument in the path slot of the structure. (stat_impl): New parameter, path. Pass argument to stat_to_struct. (statp, statl): Pass path down to stat_impl. (statf): Pass nil down as path argument of stat_impl. (sysif_init): Intern path symbol here. Add path_s to the slot list in the make_struct_type call which creates the stat structure type. * sysif.h (path_s): Declared here now. (stat_to_struct): Declaration updated. * txr.1: Documented new slot of stat structure and behavior of stat, lstat and fstat w.r.t. this slot.
* listener: :p and :prompt commands.Kaz Kylheku2017-04-061-0/+34
| | | | | | | | | * parser.c (repl): Support :p and :prompt commands for printing the current prompt, which is useful in plain mode. * txr.1: Document the new commands under Interactive Listener. Also plain mode is documented again here, though it is described for -n/--noninteractive.
* Indexing in variable subst applies to any sequence.Kaz Kylheku2017-04-051-0/+17
| | | | | | | | | | | | | | | | | | | | The @{a [3]} syntax in quasiliterals and @(output) now indexes into the original object a if it is any sequence kind, not specifically a list. Otherwise it indexes into its string representation. * eval.c (format_field): Combine the elements of the object with the separator if it is any sequence type other than a string. Subject to compat option. (subst_vars): Avoid converting any kind of sequence to string, rather than just lists. After any field formatting is applied, if the object is any sequence (not just alist), combine the elements with a space. All subect to compat option. * match.c (tx_subst_vars): Same treatment as subst_vars. * txr.1: Compatibility notes added.
* Version 174.txr-174Kaz Kylheku2017-04-041-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Connect -n option to linenoise noninteractive mode.Kaz Kylheku2017-04-041-1/+16
| | | | | | | | | | * parser.c (repl): Set noninteractive mode from noninteractive option. * txr.c (help): Mention effect of -n upon listener. * txr.1: Documented effect of -n/--noninteractive on the listener.
* New time-parse-local and time-parse-utc functions.Kaz Kylheku2017-04-041-3/+23
| | | | | | | | | | | | | | | * eval.c (eval_init): Register intrinsic functions time-parse-local and time-parse-utc. * lib.c (strptime_wrap): New static function. (time_parse): Now implemented as by call to strptime_wrap. (time_parse_local, time_parse_utc): New functions. These get the time_t time from struct tm without constructing the intermediate Lisp structure. * lib.h (time_parse_local, time_parse_utc): Declared. * txr.1: Documented new functions.
* apply and iapply bugfix: split sequences into args.Kaz Kylheku2017-04-031-1/+4
| | | | | | | | | | | | | | | | | | | | | These functions don't conform with the documentation. For instance [apply list "abc"] yields "abc". It is supposed to yield (#\a #\b #\c), since the characters of "abc" must become individual arguments to list. Part of the fix is in the apply_frob_args logic; however, we have to clone that function because it is used for implementing other things which will break: we cannot, for for example, have (list* 1 "ab") producing (1 #\a #\b). * eval.c (apply_intrisic_frob_args): New static function. Differs from apply_frob_args in that it calls tolist on the final element. (apply_intrinsic): Use apply_intrinsic_frob_args instead of apply_frob_args. (iapply): Invoke tolist on the value assigned to last_arg. * txr.1: Add a clarifying note for iapply that the terminating atom is not split into arguments if it is a sequence.
* doc: add notes to copy-struct.Kaz Kylheku2017-04-031-0/+42
| | | | | | * txr.1: copy-struct is a low-level mechanism. Higher level object cloning must be built on top of it, if required. This is now noted in the documentation.
* doc: hash-update grammar.Kaz Kylheku2017-04-021-1/+1
| | | | * txr.1: number agreement: "each values" -> "each value".
* doc: run-on paragraph under car, cdr, nullfiy method.Kaz Kylheku2017-04-021-1/+3
| | | | | * txr.1: Under the description of the car, cdr and nullify methods, the description of car must start a new paragraph.
* doc: clarify behavior of mutated keys in hashing.Kaz Kylheku2017-04-021-3/+27
| | | | | | | | | | | * txr.1: Under description of the equal method, replace the text about a hash table "not working reliably" with proper "unspecified behavior" terminology. Add some paragraphs to the introduction to hash tables about the issue of modifying the car fields of hash entry cells, or mutating the keys in equal-based hash tables such that their equality is affected. Re-iterate some of these points in a few other places under the descriptions of some hash-related functions.
* Important improvement in opip: support slot access.Kaz Kylheku2017-03-291-1/+10
| | | | | | | | | | * eval.c (me_opip): Just like dwim forms are left untransformed, we also leave untransformed (uref ...) and (qref ...) forms. Otherwise they get wrapped in the (do ...) syntax and don't work right. This treatment is so broken/useless that no compatibility switch is needed here. * txr.1: Documentation for opip/oand updated.
* Package prefix handling on directive symbols.Kaz Kylheku2017-03-271-0/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The directives which are involved in special phrase structure syntax like @(collect), @(end), @(and) and many others have always been a hack, recognized specially in the lexical analyzer and handled in the parser. The identifiers were not treated via the normal Lisp interning mechanism. In this patch, we try to make the illusion more complete and functional. Going forward, these symbols are understood as being interned in the usr package. As a special relaxation, keyword symbols may be used in their place, so that @(:end) is the same as @(end) and @(:collect) is the same as @(collect). Suppose that @(collect) is scanned, but the collect symbol interned in the current package isn't usr:collect, or keyword:collect. Then this is an error. Further, package prefixes may be used. The syntax @(abc:collect) is still valid and is still recognized as the head of the @(collect) phrase structure syntax. However, if abc:collect isn't the same symbol as either usr:collect or :collect, then an error is triggered. * parser.l (grammar): Recognize optional package prefixes on directive phrase structure identifiers. (directive_tok): Extract package prefix and symbol from lexeme. Implement the above described checks for all the cases. * txr.1: Added description of this under the Packages and Symbols section.
* Version 173.txr-173Kaz Kylheku2017-03-251-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: cross reference call-finalizers.Kaz Kylheku2017-03-241-0/+4
| | | | | * txr.1: Under finalize function mention that finalizers can also be called using call-finalizers.
* doc: reference to nonexistent special var.Kaz Kylheku2017-03-241-2/+2
| | | | | * txr.1: Fix references to nonexistent *package-list* variable under Handlers and Sandboxing.
* call-finalizers: allow recursion.Kaz Kylheku2017-03-231-1/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Code to invoke finalizers and remove them from the list is consolidated: both the gc and call-finalizers now use the same lower-level function. Finalizers may now themselves call-finalizers; it is no longer "unspecified behavior". This greatly improves the the TXR Lisp support for RAII, since :fini handlers of objects can call finalization on related objects. For instance a container being finalized can call the finalizers of contained objects. * gc.c (call_finalizers_impl): New function. Gathers all eligible finalizer registrations into a local list, first, removing them from the global list. Then does the calls in a second pass. Also, relative to the original functions which it replaces, this fixes an incorrect case: when the list is of length 1 and contains an eligible entry, in which case the global final_tail pointer is left aiming at a local variable! (is_reachable_final): New static function. (call_finalizers): Use call_finalizers_impl, specifying is_reachable_final as the predicate. (is_matching_final): New static function. (gc_call_finalizers): Use call_finalizers_impl, specifying is_matching_final as the predicate. * txr.1: Update documentation about call-finalizers.
* Bind variable during directive delimited match.Kaz Kylheku2017-03-221-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | The existing behavior is: when a situation like @a@(foo) performs a search for the match for @(foo) in order to determine the extent of the text matched by variable a, the variable a is not bound. That is to say, @(foo) is tried in an environment in which a doesn't exist. The variable is only bound when the search succeeds, and then @(foo) is processed again, with the variable now available. The new behavior is that @(foo) is tested in an environment in which a is bound. The variable's value is bound to the range of text between the original position and the tested position where @(foo) is tried. This is subject to the copatibility option. * match.c (ml_bindings_specline_pos): New static function. (search_match_binding_var): New static function, variant of search_match. (h_var): In the var-delimited-by-directive case, perform the search using search_match_binding_var, unless <= 172 compatibility is requested. * txr.1: Compatibility note added.
* listener: completion sensitive for slots and methods.Kaz Kylheku2017-03-211-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When completing .prefix[TAB], .(prefix[TAB] or .[prefix[TAB], restrict identifiers to the appropriate namespace. The former will report only symbols from the relevant package which are struct slots; the latter further restricts it to those which are static slots defined as functions. * lib.c (symbol_visible): Static function becomes extern. * lib.h (symbol_visible): Declared. * parser.c (find_matching_syms): par parameter is renamed kind and can hold additional values 'S' (slots) and 'M' (methods). New get_slot_syms function is used to fetch the slots, as necessary, instead of the visible syms, if the kind is 'S' or 'M'. The same loop as before (with the minor change of recognizing 'S' and 'M' also) performs the prefix matching. (provide_completions): Recognize . .( and .[ prefix, calculating the kind argument of find_matching_syms in a new way. * struct.c (get_slot_syms): New function. * struct.h (get_slot_syms): Declared. * txr.1: Add some notes about this under the description of completion. The full rules are not given though; let the user discover.
* Version 172.txr-172Kaz Kylheku2017-03-191-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* Restore package and package alist in handlers.Kaz Kylheku2017-03-181-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When setting up a handler frame, we note down the current package alist and package in the frame. Then when invoking the handler, we rebind the *package* and *package-alist* special variables. This is a needed security measure for sandboxing. Since handlers do not unwind (and therefore do not restore special variables) a handler in sandboxed code could catch an exception from non-sandboxed code that has changed *package* or *package-alist*, and take advantage of those changed values to escape from the sandbox. * unwind.c (uw_push_handler): Store current package and package-alist into new fields in the handler frame. (invoke_handler): Set up a new dynamic environment and bind *package* and *package-alist* around the handler call, to the values noted in the frame. Thus the handler executes with whatever package context was current when the handler was established. * unwind.h (struct uw_handler): New members, package and package_alist. * txr.1: Add paragraph to Exception Handling about this issue.
* Sandboxing support via *package-alist*.Kaz Kylheku2017-03-171-6/+62
| | | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register *package-alist* variable, taking on the contents of the packages variable. * lib.c (package_alist_s): New symbol variable. (make_package, packagep, find_package, package_alist); Work with dynamic package alist variable via cur_package_alist_loc macro. (get_current_package_alist_loc): New function. * lib.h (cur_package_alist_loc): New macro. (packages, package_alist_s, get_current_package_alist_loc): Declared. * txr.1: Documented *package-alist* along with notes about sandboxing. Documented that the package-alist function is now obsolescent.
* Document opt function.Kaz Kylheku2017-03-171-0/+38
| | | | | * txr.1: Add missing description of the opt convenience function for constructing opt-desc structures.
* New function: static-slot-home.Kaz Kylheku2017-03-161-0/+34
| | | | | | | | | | | * struct.c (struct_init): Register intrinsic function static-slot-home. (lookup_static_slot_desc_load): New static function. (static_slot_home): New function. * struct.h (static_slot_home): Declared. * txr.1: Documented.