summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* linenoise: Ctrl-Z: send SIGTSTP to group, not self.Kaz Kylheku2022-04-281-3/+3
| | | | | | | | | | | | | | | | | | | I realized this issue while implementing Ctrl-Z for the pw (Pipe Watch) program. Sending the SIGTSTP signal just to the calling process is not enough. Only that process gets suspended, which results in a weird behavior. It can be tested like this, for instance: txr | tee file Ctrl-Z must be issued twice: once to sort of suspend txr, and then again to send it to the tee program. Then the job actually suspends and the shell prompt appears. With this fix, the above situation requires only one Ctrl-Z, as expected. * linenoise/linenoise.c (history_search, show_help, edit): Don't raise(SIGTSTP), but kill(0, SIGTSTP) to send the suspend signal to all processes in the process group.
* doc: FFI string types map null pointer to nil.Kaz Kylheku2022-04-261-3/+7
| | | | | | * txr.1: Document the existing behavior that the various FFI string types map between the null pointer and the nil object.
* doc: ffi: document the array-of-1 trick.Kaz Kylheku2022-04-261-0/+62
| | | | | * txr.1: Document the (ptr (array 1 <type>)) trick needed for out or in-out parameters.
* load/@(load): use path_cat.Kaz Kylheku2022-04-252-6/+2
| | | | | | | * eval.c (load): Use path_cat and dir_name instead of ad hoc path munging. * match.c (v_load): Likewise.
* *load-search-dir*: Some tests.Kaz Kylheku2022-04-251-0/+33
| | | | | * tests/019/load-search.tl: Add some cases that explore the load search path.
* New: load can search multiple directories.Kaz Kylheku2022-04-258-19/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (load_search_dirs_s): New symbol variable. (load): Initialize the name variable whose address is passed as the third argument of open_txr_file, which is now an in-out parameter. Pass t for the new search_dirs parameter, so that load benefits from the searching. (eval_init): Initialize load_search_dirs_s and register the *load-search-dirs* special variable. * eval.h (load_search_dirs_s): Declared. (load_search_dirs): New macro. * match.c (v_load): Initialize the variable passed as third argument of open_txr_file. * parser.c (open_txr_file): Take a new argument, search_dirs. If this is t, it tells the function "if the path is not found, then recurse on the *load-search-dirs* variable. Otherwise, if the value is not t, it is a list of the remaining directories to try. The existing parameter orig_in_resolved_out must now point to a location which is initialized. It is assumed to hold the original target that was passed to the load function. The first_try_path is a the path to actually try, derived from that one. Thus, the caller of open_txr_file gets to determine the initial try path using its own algorithm. Then any recursive calls that go through *load-search-dirs* will pass a first argument which is made of the original name, combined with a search dir. (load_rcfile): Pass pointer to initialized location as third argument of open-txr_file, and pass a nil value for search_dirs: no search takes place when looking for that file, which is at a single, fixed location. * parser.h (open_txr_file): Declaration updated. * txr.c (sysroot_init): Initialize *load-search-dirs*. (txr_main): Ensure third argument in all calls to open_txr_file points to initialized variable, with the correct value, and pass t for the search_dirs argument. * txr.1: Documented. * stdlib/doc-syms.tl: Updated. New: load can search multiple directories. * eval.c (load_search_dirs_s): New symbol variable. (load): Initialize the name variable whose address is passed as the third argument of open_txr_file, which is now an in-out parameter. Pass t for the new search_dirs parameter, so that load benefits from the searching. (eval_init): Initialize load_search_dirs_s and register the *load-search-dirs* special variable. * eval.h (load_search_dirs_s): Declared. (load_search_dirs): New macro. * match.c (v_load): Initialize the variable passed as third * argument of open_txr_file. * parser.c (open_txr_file): Take a new argument, search_dirs. If this is t, it tells the function "if the path is not found, then recurse on the *load-search-dirs* variable. Otherwise, if the value is not t, it is a list of the remaining directories to try. The existing parameter orig_in_resolved_out must now point to a location which is initialized. It is assumed to hold the original target that was passed to the load function. The first_try_path is a the path to actually try, derived from that one. Thus, the caller of open_txr_file gets to determine the initial try path using its own algorithm. Then any recursive calls that go through *load-search-dirs* will pass a first argument which is made of the original name, combined with a search dir. (load_rcfile): Pass pointer to initialized location as third argument of open-txr_file, and pass a nil value for search_dirs: no search takes place when looking for that file, which is at a single, fixed location. * parser.h (open_txr_file): Declaration updated. * txr.c (sysroot_init): Initialize *load-search-dirs*. (txr_main): Ensure third argument in all calls to open_txr_file points to initialized variable, with the correct value, and pass t for the search_dirs argument. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* open_txr_file: rename parameters.Kaz Kylheku2022-04-242-20/+20
| | | | | | * parser.[ch] (open_txr_file): spec_file is now called first_try_path. The name parameter is called orig_in_resolved_out. Currently it has just the resolved_out semantics, but that is about to change.
* subprocesses: don't unnecessarily flush *stdout*.Kaz Kylheku2022-04-241-2/+4
| | | | | | * stream.c (open_subprocess, open_commad): Only flush standard output for non-input pipes. If we are capturing the output of the process, then it is unrelated to our standard output.
* subprocesses: flush *stdout*.Kaz Kylheku2022-04-231-0/+8
| | | | | | * stream.c (open-subprocess, open_command, run): Flush the standard output stream before forking or spawning the child process. This gets tests/018/forkflush.tl to pass.
* fork/streams: new failing test.Kaz Kylheku2022-04-232-0/+43
| | | | | | | | | | | | | | | | This test case exemplifies code that will work as expected when *stdout* is a TTY device, such that line buffering is in effect, but then break when standard output is redirected to a file. The issue is that the controlling process is not flushing its standard output when calling the external script, so the script's output gets placed ahead of the process' own earlier output. * tests/018/forkflush.tl: New file. * tests/018/forkflush.expected: New file.
* doc: cross reference eval and file compilation.Kaz Kylheku2022-04-011-2/+33
| | | | | | | * txr.1: The Top-Level Forms and File Compilation Model sections now reference back to eval, noting its similar treatment of top-level forms. Without this, it looks like top-level forms are just a compilation concept.
* loading: bugfix: try specified path before suffixes.Kaz Kylheku2022-03-312-61/+99
| | | | | | | | | | | | | | | | | | | | This is a partial revert of the May 1, 2019 commit 065dde19dfbe50e91e313e5b3ccc033cfbe47f74, titled "loading: try unsuffixed files directly last". Test cases added in prior commit now pass. * parser.c (open_txr_file); Like before the 2019 commit, we try the exact path that is specified first. Only if that is not found do we try adding suffixes to a file which has no recognizable suffix. This does mean that (load "foo") will probe the filesystem twice in order to find "foo.tl" or "foo.tlo" there is no obvious way around that that doesn't cause a problem. * txr.1: Update documentation that is outdated, incomplete, incorrect, or that is has become incorrect because of this fix.
* Add test for loading issue.Kaz Kylheku2022-03-3110-0/+55
| | | | | | | | | | | | | | | | | This test currently fails because when we execute an unsuffixed file like test/019/a, which exists, another file is executed instead, like test/019/a.txr. * tests/019/data/a, * tests/019/data/a.tl, * tests/019/data/a.tlo, * tests/019/data/a.txr * tests/019/data/b.tl * tests/019/data/b.tlo * tests/019/data/b.txr * tests/019/data/c.tl * tests/019/data/c.txr * tests/019/load-search.tl: New files.
* compiler: package-manipulating top-level forms bug.Kaz Kylheku2022-03-311-1/+2
| | | | | | | | | | | | | | * stdlib/compiler.tl (compile-file-conditionally): Recognize a potential package-manipulating form not checking whether its main operator is in %pakage-manip% list, but whether any global functions that its compiled image references are in that list. This is the same approach that is used in dump-compiled-objects. This fix is needed for correctly recognizing defpackage as a package-manipulating form. defpackage macro-expands to a let form which contains a call to make-package. Testing whether let is in %package-manip% is useless; of course it isn't, and the test overlooks make-package.
* New function: isecp.Kaz Kylheku2022-03-306-7/+52
| | | | | | | | | | | | | | | | | * eval.c (eval_init): Register isecp intrinsic. * lib.c (isecp): New function. * lib.h (isecp): Declared. * stdlib/compiler.tl (lambda-apply-transform, dump-compiled-objects): Use isecp instead of isec, since the actual intersection of symbols isn't needed, only whether it exists. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* Test of a package-related file compilation problem.Kaz Kylheku2022-03-302-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This test currently fails. This problem was reported by Paul Patience, with a repro test case. The issue is that when compile-file is processing a (defpackage x ...) form, and the package x already exists, it fails to recognize the form as a package-manipulating form, and therefore fails to introduce a "fence" in the output so that subsequent material is placed into a new top-level object. The compiled image fo the (defun foo:fun ()) form in program.tl causes an error: the foo package does not exist. This is because the symbol foo:fun is being read as part of the same object which holds the compiled image of the defpackage form which defines the package. It's essentially the same problem as this (let () (defpackage :foo) foo:bar) The (defpackage ...) cannot execute until the entire form is read, but that form contains foo:bar which requires the foo package to exist. * tests/019/compile-package.tl: New file. * tests/019/data/program.tl: Likewise.
* New FFI types str-s, bstr-s and wstr-s.Kaz Kylheku2022-03-214-54/+143
| | | | | | | | | | | | | | | | | These types actually make it possible to receive a string by pointer from a C function, without trying to free it. It is now possible to write a FFI wrapper for strtol or wcstol, which is done in the new test case. * ffi.c (str_s_s, bstr_s_s, wstr_s_s): New symbol variables. (ffi_init_types): Register the types str-s, bstr-s and wstr-s. (ffi_init): Intern the new symbols. * tests/017/str-s.tl: New file. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* ffi: minor code reordering in initialization.Kaz Kylheku2022-03-201-4/+6
| | | | | * ffi.c (ffi_init_types): Move initialization of str-d type from just before wstr to after, for consistency.
* configure: bugfix in shell escaping codeKaz Kylheku2022-03-181-1/+1
| | | | | | | | | | | * configure: in the case when the argument contains single quotes, we try to identify the subcase that cannot use double quotes instead. That subcase is not correctly identified: it occurs when there are double quotes, dollar signs **or backslashes**. For instance the data '\ cannot be put into double quotes as "'\" on account of the backslash, which is an active character in double quotes. We also simplify the pattern by using a character class.
* configure: missing tab in shell escaping code.Kaz Kylheku2022-03-181-1/+1
| | | | | | * configure: a certain ' ' (four spaces between single quotes is actually supposed to be a tab; it must have been expanded by the editor.
* ffi: after call, process args in reverse order.Kaz Kylheku2022-03-171-11/+10
| | | | | | | | | | | | | | | | | | | | | | | | | In FFI foreign function and closure calls, it behooves us to iterate over the arguments in the opposite order after the call is done. By doing that, any freeing of memory that will be done will be in the opposite order. And that is necessary if some left argument allocates a pointer that is shared with a right argument. An example of this occurs in the strtol function: long int strtol(const char *nptr, char **endptr, int base); Here, the function sets *endptr to a value derived by displacing ptr. If we call this function via FFI, then FFI will allocate memory for nptr. When the function returns, if we destroy that memory before processing *endptr then *endptr contains an invalid pointer. * ffi.c (ffi_call_wrap): In the in pass, iterate arguments in reverse. (ffi_closure_dispatch, ffi_closure_dispatch_safe): Stack-allocate an array for the argument types, so we don't have to pop the list twice, and to allow access in reverse order. In the out pass, iterate arguments in reverse.
* doc: sort-group: unnecessary copyKaz Kylheku2022-03-161-1/+1
| | | | | * txr.1: Remove copy operation partition-by expression; this was needed when sort was destructive.
* ffi: support intmax-t and uintmax-t types.Kaz Kylheku2022-03-154-9/+62
| | | | | | | | | | | | | * configure: detect intmax_t and place HAVE_INTMAX_T into config.h. * ffi.c (ffi_init_extra_types): register intmax-t and uintmax-t types. If HAVE_INTMAX_T is missing, then make them aliases for longlong and ulonglong. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New GNU-themed quip.Kaz Kylheku2022-03-081-0/+1
| | | | | | * stdlib/quips.tl (%quips%): Samsung spelled backwards is gnusmaS. In December, don't wish Merry GNUsmas in a GNU mailing list.
* New function: group-map.Kaz Kylheku2022-03-025-9/+51
| | | | | | | | | | | | * hash.c (group_map): New function. (hash_init): group-map intrinsic registered. * hash.h (group_map): Declared. * tests/010/hash.tl: New test case. * txr.1: Documented together with group-by. Extra paren removed from group-by example.
* hash: add tests for group-by, group-reduce.Kaz Kylheku2022-03-021-0/+16
| | | | * tests/010/hash.tl: New tests.
* hash: group-reduce calls hash-update.Kaz Kylheku2022-03-021-9/+3
| | | | | | | * hash.c (group_reduce): Replace loop with call to hash_update which is exactly the same logic, and even more efficient because it avoids calling us_rplacd. (hash_update): Fix incorrect self name.
* Version 274.txr-274Kaz Kylheku2022-02-247-859/+1003
| | | | | | | | | | | | | | * RELNOTES: Updated. * configure (txr_ver): Bumped version. * stdlib/ver.tl (lib-version): Bumped. * txr.1: Bumped version and date. * txr.vim, tl.vim: Regenerated. * protsym.c: Likewise.
* opip: pass through forms in the op family.Kaz Kylheku2022-02-243-5/+28
| | | | | | | | | | | | | | * stdlib/op.tl (sys:opip-expand): Add op, do, lop, ldo, ap, ip, ado, ido, ret and aret to the operators whose forms are passed through untransformed. This is important because it lets us override the implicit (op ...) and (do ...) chosen by the expander. When a pipeline element produces a list, for instance, we want to be able to use (ap ...) in the next element to spread the list into arguments. * tests/012/op.tl: Add bellied numbers test case. * txr.1: Documented.
* doc: revisit partition-ifKaz Kylheku2022-02-231-7/+26
| | | | | * txr.1: Add introductory paragraph, and fine-tune the rest of the documentation.
* doc: make-like can take an iterators.Kaz Kylheku2022-02-231-0/+10
| | | | | | * txr.1: A December 2021 change that went into TXR 273 allows iterators from iter-begin to be the object argument to the make-like function. This is now documented.
* New list-builder method: oust.Kaz Kylheku2022-02-235-6/+70
| | | | | | | | | | | | | | | | * autoload.c (build_set_entries): Add oust symbol. * stdlib/build.tl (list-builder postinit): Call the self argument self instead of bc, for consistency with other methods. (list-builder oust): New method. (list-builder-flets): Add local function oust. * tests/012/seq.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New function: partition-if.Kaz Kylheku2022-02-236-0/+199
| | | | | | | | | | | | | | | | * eval.c (eval_init): Register partition-if intrinsic. * lib.c (partition_if_countdown_funv, partition_if_func): New functions. (partition_if): New function. * lib.h (partition_if): Declared. * tests/012/seq.tl: New test cases. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* find-max: convert to seq_info iteration.Kaz Kylheku2022-02-223-87/+36
| | | | | | | | | | | | * lib.c (find_max): Simplify into a single loop rather than handling various sequence types specially. This means it works for all iterable objects now. * txr.1: find-max documentation updated; discussion of hash tables removed, since the described behavior is the one expected for hash tables as iterables. * tests/012/seq.tl: Add some test coverage.
* gc: c++ fix in type_t conversion.Kaz Kylheku2022-02-222-3/+3
| | | | | | | | | | | | | | * gc.c (sweep_one): The recent fix to address the clang diagnostic from -fsanitize=implicit-conversion broke C++ compatibility, due to enums being type safe. We revert the expression to the original, before that fix, and address the clang diagnostic differently. * gc.h (REACHABLE, FREE): Add a U suffix to the constants to make them unsigned. The implicit conversion issue in the expression convert(type_t, block->t.type & ~REACHABLE) is that ~REACHABLE is -257, and is being converted to unsigned.
* termios: overflow in initialization on 32 bits.Kaz Kylheku2022-02-221-2/+2
| | | | | | | * termios.c (termios_init): The CMSPAR and CRTSCTS constants cannot be passed to num_fast; they are out of range, and so the corresponding cmspar and crtscts variables will end up with garbage values.
* New functions: find-max-key and find-min-key.Kaz Kylheku2022-02-215-0/+76
| | | | | | | | | | | | | * eval.c (eval_init): Register find-max-key and find-min-key intrinsics. * lib.c (find_max_key, find_min_key): New functions. * lib.h (find_max_key, find_min_key): Declared. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* listener: restore and improve method completion.Kaz Kylheku2022-02-193-44/+7
| | | | | | | | | | | | | | | | | | | | | The recent autoload changes have degraded method completion, which didn't work well in the first place. Test case: with this change you can type term.(go[Tab] to complete to term.(go-raw or term.(go-cbreak. * parser.c (find_matching_syms): Do not use the get_slot_syms function for finding method and slot symbols. Just use get_visible_syms, like for other bindings. Instead, in the switch statement in the loop, for the 'M' (method) and 'S' (slot) completion types, we use the static_slot_types and slot_types functions to inquire whether a symbol has a binding. And these two functions do something important: unlike get_slot_syms, they trigger autoload. * struct.c (get_slot_syms): Function removed. * struct.h (get_slot_syms): Declaration removed.
* autoload: move socket material into socket module.Kaz Kylheku2022-02-194-72/+70
| | | | | | | | | | | | | | | | | * autoload.c (sock_set_entries, sock_instantiate): Functions removed from here. (autoload_init): autoload_reg call for above functions removed from here. (autoload_intern): New function, wrapper for intern_only. sock_set_entries uses intern_only which is static, so we need to expose this. * autoload.h (autoload_intern): Declared. * socket.c (sock_set_entries, sock_instantiate): Functions moved here. intern_only call replaced with autoload_intern. (sock_load_init): Function removed: body moved into sock_instantiate, which no longer calls sock_load_init.
* autoload: move termios material into termios module.Kaz Kylheku2022-02-192-25/+22
| | | | | | | | | | | * autoload.c (termios_set_entries, termios_instantiate): Static functions removed from here. (autoload_init): autoload_reg call for above functions removed from here. * termios.c (termios_set_entries, termios_instantiate): Static functions moved here. (termios_init): autoload_reg call moved here.
* autoload: use weak hash to erase registrations.Kaz Kylheku2022-02-194-99/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In autoload the _set_entries functions are being called twice: the first time with a functional argument to associate symbols with that function, and then when the module is loaded, a second time with a nil argument to erase those associations. This is inefficient; some modules have many symbols to remove from a hash. What we can do is make the hash weak; associate the symbols with a function weakly, such that those entries lapse when the function becomes garbage. Lapsing of weak hash table entries during GC is more efficient than making numerous calls to remhash. We can use a separate strong hash table to hang on to the functions; when a module is instantiated, all we have to do is remove the instantiation function from the table. Then that function is reachable only as a weak value from the other tables. * autoload.c (autoload_reg_hash): New static variable. (place_instantiate, ver_instantiate, ifa_instantiate, txr_case_instantiate, with_resources_instantiate, path_test_instantiate, struct_instantiate, with_stream_instantiate, hash_instantiate, except_instantiate, type_instantiate, yield_instantiate, sock_instantiate, termios_instantiate, awk_instantiate, build_instantiate, trace_instantiate, getopts_instantiate, package_instantiate, getput_instantiate, tagbody_instantiate, pmac_instantiate, error_instantiate, keyparams_instantiate, ffi_instantiate, doloop_instantiate, stream_wrap_instantiate, asm_instantiate, compiler_instantiate, debugger_instantiate, op_instantiate, save_exe_instantiate, defset_instantiate, copy_file_instantiate, arith_each_instantiate, each_prod_instantiate, quips_instantiate, match_instantiate, doc_instantiate, pic_instantiate, constfun_instantiate): Remove set_fun argument and call to that function. (autoload_reg): Remove argument from instantiate function. Add the function to the autoload_reg_hash table, associated with the t symbol. (autoload_init_tables): Initialize autoload_reg_hash. Turn the existing symbol hashes into weak tables. Let's use weak or-semantics, so they don't hang onto uninterned symbols. (autoload_try): If a symbol resolves to a function, indicating a load might be required, we now must verify whether that is really the case by seeing whether the function exists in the autolod_reg_hash table. If so, we remove it from that table and do the load. * autoload.h (autoload_reg): Declaration updated. * gencadr.txr (cadr_register): Remove set_fun argument and call to that function. * cadr.c: Regenerated.
* doc: or-semantics misformatted.Kaz Kylheku2022-02-191-1/+1
| | | | | * txr.1: In description of make-hash, fix bungled typesetting of "or-semantics".
* lisplib: rename to autoload.Kaz Kylheku2022-02-186-16/+16
| | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS): rename lisplib.o to autoload.o. * lisplib.c: Renamed to autoload.c. (lisplib_init_tables): Renamed to autoload_init_tables. (lisplib_init): Renamed to autoload_init, and calls autoload_init_tables. (lisplib_try_load): Renamed to autoload_try. (autoload_try_fun, autoload_try_var, autloload_try_slot, autoload_try_struct, autoload_try_keyword): Follow rename. * lisplib.h: Renamed to autoload.h. (lisplib_init): Renamed to autoload_init. * eval.c: Include autoload.h. (eval_init): Follow rename of lisplib_init. * gencadr.txr: include "autoload.h" * cadr.c: Regenerated.
* lisplib: rename lisplib funtions to autoload prefix.Kaz Kylheku2022-02-185-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisplib.c (lisplib_init): Follow rename, and rename try-load-fun to autoload-try-fun. (lisplib_try_load_fun, lisplib_try_load_var, lisplib_try_load_fun_var, lisplib_try_load_slot, lisplib_try_load_struct, lisplib_try_load_keyword): Renamed from `lisplib_try_load_@kind` to `autoload_try_@kind`. * lisplib.h (lisplib_try_load_fun, lisplib_try_load_var, lisplib_try_load_fun_var, lisplib_try_load_slot, lisplib_try_load_struct, lisplib_try_load_keyword): Declarations renamed. * eval.c (lookup_global_var, lookup_sym_lisp1, lookup_fun, lookup_mac, lookup_symac, lookup_symac_lisp1, special_var_p, expand_param_macro, rt_defvar, rt_defv, op_defsymacro, rt_defsymacro, rt_defun, rt_defmacro, makunbound, fmakunbound, mmakunbound): Follow rename. * struct.c (make_struct_type, find_struct_type, lookup_slot_load, lookup_static_slot_load, lookup_static_slot_desc_load, slot_types, static_slot_types): Follow rename. * stdlib/place.tl (get-place-macro): Follow rename of try-load-fun to autoload-try-fun.
* socket: add missing autoload entries for sockopts.Kaz Kylheku2022-02-181-1/+11
| | | | | | * lisplib.c (sock_set_entries): Add autoload entries for a number of socket-relatd variables that were recently moved out of the FFI module (no part of which auto-loads) into socket.c.
* lisplib: split autoload entries into namespaces.Kaz Kylheku2022-02-184-243/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Autoloads are now keyed to spearate namespaces for functions/macros, variables, structures, slots and a keyword namespace for autoloading miscellaneous things tied to keywords like parameter macros. There is some renaming going on as part of this. The "dlt" acronym is replaced by "autload". Some functions in lisplib.c were in an inconsistent order, and were reordered. Motivation: the one namespace autoload causes hidden problems in the standard library, due to inappropriate loads. This shows up particularly when then uncompiled library is used. Tests no longer execute as they should. Story time: when struct.tl is autloaded, it loads param.tl for parameter parsing, param.tl defines a structure that has an opt slot, and accesses it with an expression like me.opt. When this expression is expanded, the qref macro checks whether opt is a valid slot, and for that, autoload is triggered. But, oops, opt is a function in getopts.tl, Thus param.tl autoloads getopt.tl. Paul A. Patience recently introduced changes into getopt.tl that make use of pattern matching. So getopt.tl auto-loads match.tl. But match.tl uses structures. But, oops, that material is defined in struct.tl, which is in progress of being auto-loaded. Thus, a false circular dependency exists, caused by a check of the opt slot triggering the loading of the irrelevant getopts.tl module. These irrelevant loads will also slow down the compiling of the library also, as well as test cases when the library is not compiled: especially tests run under the GC torture test. * lisplib.c (dl_table): Global variable removed. (autoload_hash): New static array. (set_dlt_entries_impl): Renamed to autoload_set_impl. (autoload_set_impl): Takes al_ns_t namespace enum argument. Operates on the hash table indicated by that argument. (set_dlt_entries): Renamed to autoload_set. (set_dlt_entries_sys): Renamed to autoload_sys_set. (autoload_key_set): New static function. (place_set_entries, ver_set_entries, ifa_set_entries, txr_case_set_entries, with_resources_set_entries, path_test_set_entries, struct_set_entries, with_stream_set_entries, hash_set_entries, except_set_entries, type_set_entries, yield_set_entries, sock_set_entries, termios_set_entries, awk_set_entries, build_set_entries, trace_set_entries, getopts_set_entries, package_set_entries, getput_set_entries, tagbody_set_entries, pmac_set_entries, error_set_entries, keyparams_set_entries, ffi_set_entries, doloop_set_entries, stream_wrap_set_entries, asm_set_entries, compiler_set_entries, debugger_set_entries, op_set_entries, save_exe_set_entries, defset_set_entries, copy_file_set_entries, arith_each_set_entries, each_prod_set_entries, quips_set_entries, match_set_entries, doc_set_entries, pic_set_entries, constfun_set_entries): Separate name arrays into multipel namespaces as appropriate and register using approprate namespace enums. (dlt_register): Renamed to autoload_reg. (autoload_reg): dlt parameter removed. (lisplib_try_load): Take namespace enum argument, and check against the corresponding hash. (lisplib_try_load_fun, lisplib_try_load_var, lisplib_try_load_slot, lisblib_try_load_struct, lisplib_try_load_keyword): Pass appropriate enum value to lisplib_try_load to request the right namespace. (lisplib_try_load_fun_var): Call lisplib_try_load_fun, and if that does nothing, lisplib_try_load_var. (lisplib_init_tables): New function. (lisplib_init): References to dl_table removed. Call to dlt_register replaced with autoload_reg. * lisplib.h (dl_table): Declaration removed. (enum autoload_ns, al_ns_t): New enum. (set_dlt_entries, dlt_register): Declarations removed. (autoload_set, autoload_reg): Declared. * gencadr.txr (cadr_set_entries): Drop dlt parameter, call autoload_set instead of set_dlt_entries. (cadr_init): Call autoload_reg instead of dlt_register. * cadr.c: regenerated.
* lisplib: split lisplib_try_load into namespaces.Kaz Kylheku2022-02-185-29/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisplib.c (lisplib_init): Change sys:try-load (only used by place.tl) to sys:try-load-fun, and register it to (lisplib_try_load): External function becomes static. (lisplib_try_load_fun, lisplib_try_load_var, lisplib_try_load_fun_var, lisplib_try_load_slot, lisplib_try_load_struct, lisplib_try_load_keyword): New functions. * lisplib.h (lisplib_try_load): Declaration removed. (lisplib_try_load): External function becomes static. (lisplib_try_load_fun, lisplib_try_load_var, lisplib_try_load_fun_var, lisplib_try_load_slot, lisplib_try_load_struct, lisplib_try_load_keyword): Declared. * eval.c (lookup_global_var, lookup_var, lookup_symac, lookup_symac_lisp1, rt_defvarl, rt_defv, op_defsymacro, rt_defsymacro, makunbound): Use lisplip_try_load_var. (lookup_fun, lookup_mac, rt_defun, rt_defmacro, fmakunbound, mmakunbound): Use lisplib_try_load_fun. (expand_param_macro): Use lisplib_try_load_keyword, which is a catch-all namespace for anything tied to keywords. * struct.c (make_struct_type, find_struct_type): Use lisplib_try_load_struct. (lookup_sloat_load, lookup_static_slot_load, lookup_static_slot_desc_load, slot_types, static_slot_types): Use lisplib_try_load_slot. * stdlib/place.tl (get-place-macro): Use try-load-fun, rather than try-load.
* compiler: autoload on sys:*in-compilation-unit*.Kaz Kylheku2022-02-171-1/+1
| | | | | | | | | | | | | The compiler module contains the with-compilation-unit macro; if that macro is used, it is auto-loaded. However, when a file that uses with-compilation-unit is compiled, the macro is gone; its expansion refers to the sys:*in-compilation-unit* which is defined in the compiler module also. However, there is no autoload set up for it. * lisplib.c (compiler_set_entries): Add sys:*in-compilation-unit* to the list of symbols that trigger autoloading.
* ffi: move socket stuff to socket module.Kaz Kylheku2022-02-175-108/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * alloca.h (zalloca): Macro moved here from ffi.c; it's useful to any code that wants to do a zero-filled alloca, and socket.c needs it now. * ffi.c (HAVE_SOCKETS): All includes conditional on HAVE_SOCKETS removed. (zalloca): Macro removed; moved to alloca.h. (ffi_type_struct_checked, ffi_type_lookup): Static functions changed to external linkage. (ffi_type_size, ffi_type_put, ffi_type_get): New functions, used by external module that has incomplete definition of struct txr_ffi_type. (type_by_size): New static array, moved out of ffi_init_extra_types function. (ffi_type_by_size): New function. (ffi_init_extra_types): type_by_size array relocated to file scope. (sock_opt, sock_set_opt): Moved to socket.c, and adjusted to use newly developed external access to needed ffi mechanisms. (ffi_init): Numerous definitions related to sockets removed; these go to socket.c. * ffi.h (struct txr_ffi_type): Declared here now as incomplete type. (ffi_type_struct_checked, ffi_type_size, ffi_type_put, ffi_type_get, ffi_type_lookup, ffi_type_by_size): Declared. * lib.c (init): Call new function sock_init. * socket.c (sock_opt, sock_set_opt): New functions, moved from ffi.c, and slightly adapted to work with external interfaces exposed by ffi.c. (sock_init): New function. This performs unconditional initializations not keyed to the lazy loading lisplib.c mechanism. Here we create the socklen-t FFI type. FFI types lookup doesn't trigger lazy loading, so we do it this way; the alternative would be to introduce lazy load triggering to FFI type lookup, just for this one type. (sock_load_init): All the socket function and variable registrations move here from ffi_init.
* doc: extend fboundp dialect note.Kaz Kylheku2022-02-171-2/+10
| | | | | | * txr.1: Mention that ANSI CL's fboundp doesn't yield true for lambda expressions, and how that affects the example expression's fidelity.