summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* hash: remove unnecessary tests in weak processing.Kaz Kylheku2021-07-201-4/+3
| | | | | | * hash.c (do_weak_tables): Do not test hash entries for reachability, only keys and values. This is not worth doing and possibly adds cycles.
* hash: fix possibly incorrect counts in weak processing.Kaz Kylheku2021-07-201-16/+11
| | | | | | | * hash.c (do_weak_tables): Iterate to the end of each chain, not quitting early when a reachable tail is found. This has the effect that we will always count the nodes properly. Some common code is factored out of the switch also.
* hash: revert bad fix in weak processing.Kaz Kylheku2021-07-202-20/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit reverts the April 11, 2020 commit a4c376979d15323ad729e92e41ba43768e8dc163, subject line "hash: bugfix: spurious retention in weak processing". That commit is a regression. This revert requires a follow-up; the commit was trying to fix an issue which now reappears. It will have to be fixed differently. The regression is that in a situation in which data is referenced through two or more dependent weak tables, entries that are reachable can spontaneously disappear from downstream tables. Suppose H0 and H1 are weak-key tables. Suppose the program holds a datum K0, which is the only reference through which D1 is reached, in the following chain: K0 -> [H0] -> K1 -> [H1] -> D1 K0 is a key in hash table H0, which has weak keys. The the associated value K1 is a key in H1, which then references D1. H0 holds the only reference to K1, and H1 holds the only reference to D1. During the first GC marking phase, because we do not mark any part of a table which has weak keys, when we process H0 we do not mark the value K1. Thus K1 looks unreachable. In the second weak hash processing pass, because K1 was treated as unreachable, the <K1, D1> entry in H1 is incorrectly expired. This issue affects TXR's origin_hash and form_to_ln_hash, which are in this relationship. The problem was uncovered in recent tags.tl work, manifesting as a spurious disappearance of line number info when processing .txr files. The line number info disappeared for entries which were traced through the origin_hash via the macro-ancestor function (see the unexpand function in tags.tl). * hash.c (hash_mark): Only skip marking tables that have both weak keys and values. For weak key tables, mark all the values and vice versa: for weak value tables, mark the keys. * txr.1: Text resembling original text restored.
* op: set nested flag in correct context.Kaz Kylheku2021-07-192-10/+31
| | | | | | | | | | | | * stdlib/op.tl (sys:op-meta-p): Return an extended Boolean value: a true result is an integer indicating the depth of the variable. For instance @1 is depth 0, @@1 is depth 1 and so on. (sys:find-parent): New function. (sys:op-alpha-rename): When processing a nested meta, do not set the nested flag in the immediate parent. Use find-parent to go up to the correct level to which the meta belongs and set the flag there. * tests/012/op.tl: New test cases which depend on this.
* op: rename argument for consistency.Kaz Kylheku2021-07-191-2/+2
| | | | | | * stdlib/op.tl (sys:op-meta-p): Rename expr argument to exp. The symbol is not causing an issue here, but it's good to rename it for consistency with sys:op-rec-p and to thwart future problems.
* op: consolidate testing for @rec/@(rec ...)Kaz Kylheku2021-07-191-6/+6
| | | | | | | | | * stdlib/op.tl (sys:op-rec-p): Test for both the variable @rec and the expresson @(rec ...). Also, the expr argument of the function is renamed to exp because it causes a problem, due to that symbol, sys:expr, being the meta indicator. (sys:op-ensure-rec): Remove one test for (sys:var usr:rec), since sys:op-rec-p does it. Convert one equal-test to a call to sys:op-rec-p.
* op: fix bug in do.Kaz Kylheku2021-07-192-32/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The June 30 09e70c914ca83b5c7405aa633864db49f27efa05, subject "op: refactor do handling", introduced a regression breaking the tags.tl program. An implicit argument gets inserted twice: [[(do op list @1)] 'x] -> (x x) ;; incorrect/weird This was spotted by Paul A. Patience while working on extending tags.tl for Emacs. It's not exactly a regression because the original behavior is not documented or tested, and has issues; we simply cannot roll back the commit; a proper fix is required. How the above call is now supposed to work is that: - the @1 parameter belongs to the op, not to the do. - the do therefore has no explicitly given parameters of its own. - therefore the do inserts its parameter. In other words (do op list @1) is formally equivalent to (do op list @1 @@1). Both levels of function indirection require an argument: [[(do op list @1) 'x] 'y] -> (y x) [[(do op list @1 @@1) 'x] 'y] -> (y x) * stdlib/op.tl (sys:op-ctx): The structure gets a new slot, nested, which is a flag indicating whether unprocessed nested metas occur. This is critically needed because the sys:op-alpha-rename passes which are called with do-nested-metas being false do not insert nested metas into the gens list; they transform them and leave them in the syntax. Yet we must make decisions based on their presence. Conretely, we must be able to tell that (do op list @@1) has a meta against the outer (do ...), while we are just processing the do. (sys:op-alpha-rename): When replacing a nested meta syntax with the macro invocation, we set the nested flag of the parent context true. (sys:op-expand): Bring back the do-gen; we need it. We cannot simply insert @1 into the syntax, because that is not lexically transparent. If we add @1 to (do op ...) then that @1 is interpreted as belonging to the op, not to the do. We must also check the new Boolean flag nested to properly detect whether we have metas, including unexpanded nested metas. * tests/012/op.tl: New test cases combining (do op ...).
* tags: add support for etags format.Paul A. Patience2021-07-181-21/+82
| | | | | | | | | | | | | | | | | | | | | * tags.tl (etag-sec-start, etag-pat-end, etag-name-end): New variables. (tags-opts): Improve --help option's help message. Add -o/--output and -e/--emacs options. (tag): Add linum and byte slots. Add etext method. (file-tag): Initialize type slot to "F", and use it in the text method. (get-pat): Rename to... (get-pos-pat): ...this, and return the line number and byte offset in addition to the escaped line. (with-tag-shorthand-macro): Initialize linum and byte slots. Remove a needless splice (of the get-pat/get-pos-pat calls). (collect-tags-tl, collect-tags-txr): Add clarifying comments. (write-tagfile): Make use of new -o/--output option. (write-etagfile): New function. (toplevel): Set a default value for o.output if -o/--output is empty or missing. Disallow combination of --emacs and --merge. Remove unused variable have-arv. Fix double @1 appearing in calls to fnmatch from excf. Call write-etagfile instead of write-tagfile if --emacs was provided.
* doc: reproducible PDF.Kaz Kylheku2021-07-172-0/+23
| | | | | | | * Makefile (txr-manpage.pdf): If SOURCE_DATE_EPOCH exists, then run pdf-clobber-stamps.tl. * pdf-clobber-stamps.tl: New file.
* abs-path-p: rewrite in lower-level C.Kaz Kylheku2021-07-151-23/+34
| | | | | | | | | * stream.c (ap_regex): Static variable removed. (volume_prefix_p): New function. (abs_path_p, portable_abs_path_p): Get wchar_t * string from path and manipulate using C idioms. Use volume_prefix_p function for testing for drive letter or UNC prefix. (stream_init): Remove reference to ap_regex.
* paths: new tests.Kaz Kylheku2021-07-151-0/+46
| | | | | * tests/018/path.tl: test coverage for abs-path-p and portable-abs-path-p.
* lib: default_arg_strict becomes macro.Kaz Kylheku2021-07-141-4/+1
| | | | | | | | | | | * lib.h (default_arg_strict): Inline function converted to macro, so that we can suppress the evaluation of the default expression if it is not required. The default_arg_strict idiom is being used all over the stream library now. The common default value expressions like std_out are macros that access the dynamic variable by symbol. We don't want to be wastefully doing that on each stream operation, whether or not a stream argument has been supplied.
* build: recompile txr.c if build_id changes.Kaz Kylheku2021-07-141-2/+9
| | | | | | | | | | | | | | | | | | With this change, it is possible to make build_id=abcd to rebuild TXR with the given build ID. Any changes in the value of a dynamic, git-generated build_id will likewise trigger a rebuild. * Makefile (old_build_id): New variable. We read the old build ID from a file called .build_id in the build directory. If it differs from the current expanded ID, build_id_exp, we remove the object files affected by build_id. In all cases, we then write the current build ID into the .build_id file. (clean, distclean): Remove .build_id.
* sysif: create rlim struct even without HAVE_RLIM.Kaz Kylheku2021-07-141-3/+1
| | | | | | | | | | The reason for this change is that we don't want syntax like #S(rlim cur 0 max 0) to fail to read in a build of TXR that happens not to have detected getrlimit. * sysif.c (rlim_s, cur_s, max_s, rlim_st): Define variables unconditionally. (sysif_init): Initialize variables unconditionally.
* tests: fix stack overflow test case for old gmake.Kaz Kylheku2021-07-141-2/+7
| | | | | | | | | | | | | | | * tests/012/stack.tl: The (if stack-limited ...) test is not correct because even if gerlimit indicates an unlimited stack, we impose a defualt limit, and so (get-stack-limit) returns a an integer value. The idea here was to try to skip this test case when the stack usage is unlmited, which happens under older versions of GNU make, before posix_spawn was introduced. Instead, let's execute this test case only if we have setrlimit. In the forked child, we try to impose a small stack limit that will give use the stack overflow crash we are testing for. The objective of the test case is to validate that when (set-stack-limit 0) is called, the child will abort due to a signal, rather than (recur) returning :so.
* doc: warm-up-period argument of make-random-state.Kaz Kylheku2021-07-131-7/+14
| | | | | | * txr.1: Add missing requirement: warm-up is also not performed if make-random-state is a vector. Improve the wording overall.
* rand: support buffers as random seeds.Kaz Kylheku2021-07-133-6/+129
| | | | | | | | | * rand.c (make_random_state): Recognize buffer object as sources of bits for seeding. * tests/013/rand.tl: New file. * txr.1: Documented.
* rand: remove unnecessary type check.Kaz Kylheku2021-07-131-2/+1
| | | | | | * rand.c (make_random_state): We dn't have to use cobj_handle here because the object isn't an argument; we just instantiated in the same scope, with the correct type.
* New functions: getrlimit, setrlimit.Kaz Kylheku2021-07-134-1/+170
| | | | | | | | | | | | | | | | * stdlib/doc-syms.tl: Updated. * sysif.c (rlim_s, cur_s, max_s): New symbol variables. (rlim_st): New variable. (getrlimit_wrap, setrlimit_wrap): New functions. (sysif_init): gc-protect rlim-st. Initialize symbol vsariables. Create rlim struct type. Register getrlimit and setrlimit intrinsics. Register variables rlim-saved-max, rlim-saved-cur, rlim-infinity, rlimit-core, rlimit-cpu, rlimit-data, rlimit-fsize, rlimit-nofile, rlimit-stack and rlimit-as. * txr.1: Documented under new Unix Resource Limits section.
* sysif: bug: bogosity in protect call.Kaz Kylheku2021-07-131-1/+1
| | | | | * sysif.c (sysif_init): The address of dirent_st must be registered with protect, not the value.
* configure: tone down language.Kaz Kylheku2021-07-131-1/+1
|
* tests: guix fixes.Kaz Kylheku2021-07-135-4/+11
| | | | | | | | | | | | | | | | * tests/002/query-1.txr: Skip test if an executable /bin/sh doesn't exist, rather than the bogus reasons. * tests/010/json.tl: Change the condition for the command-put-json tests: not whether cat is found in the search path but whether /bin/sh exists and is executable. * tests/017/realpath.tl: Also quit if /usr/bin doesn't exist. * tests/018/path-test.tl: Exit succesfully if /bin/sh does not exist. Revert the earlier change. * tests/018/process.tl: Quit if no executable /bin/sh exists.
* Version 266.txr-266Kaz Kylheku2021-07-047-1323/+1365
| | | | | | | | | | | | | | * 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.
* tests: weaken condition in path search for sh.Kaz Kylheku2021-07-121-1/+1
| | | | | | | * tests/018/path-test.tl: In the Guix build environment, the shell might be found at a path not ending in bin. Let's ust test for ending in /bin. Reported and investigated by Paul A. Patience.
* tests: json: skip tests relying on cat, if missing.Kaz Kylheku2021-07-121-7/+9
| | | | | | | * tests/010/json.tl: skip several test cases which rely on the cat utility for testing command-put-json, if the cat utility is not found in the search path. Reported and investigated by Paul A. Patience.
* tests: json: fix accidentally excluded tests.Kaz Kylheku2021-07-121-2/+2
| | | | | | * tests/010/json.tl: Fix several tests being excluded from the (mtest ...) form to which they are expected to belong, one of them having an extra quote in the expected value, too.
* tests: 002 group: skip test if utils missing.Kaz Kylheku2021-07-121-0/+2
| | | | | | * tests/002/query-1.txr: Terminate with status 13 if the needed utils cannot be found in the search path. Reported and investigated by Paul A. Patience.
* tests: .txr tests can skip using exit code 13.Kaz Kylheku2021-07-121-5/+6
| | | | | * Makefile (tst/%.ok): If a .txr test terminates with status 13, that indicates that it should be skipped.
* doc: interchange first two args of json put funs.Paul A. Patience2021-07-111-6/+6
| | | | | | txr.1: Interchange the first and second arguments of file-put-json, file-put-jsons, file-append-json, file-append-jsons, command-put-json and command-put-jsons.
* txr: fix inappropriate "takes no argument".Kaz Kylheku2021-07-111-5/+43
| | | | | | | | | | | | | | txr is reporting "option --<foo> takes no argument" for any unknown option <foo>, which is silly. * txr.c (no_dbg_support): Drop setuid privilege here before doing the output. (txr_main): Block that diagnoses "takes no argument" is now reachable only by goto. Every no-argument option tests the org variable and branches there if there are arguments. Some rearrangement of drop_privilege() calls and insertion of missing ones via it now being called in no_dbug_support.
* configure: adjust comment in config.make.Kaz Kylheku2021-07-111-1/+2
| | | | | | * configure (gen_config_make): Maintenance in comment above top_srcdir. It obviously does not hold an absolute path in the case when it is blank.
* New: build-id feature.Kaz Kylheku2021-07-114-0/+51
| | | | | | | | | | | | | | | | | | | | | | A build-id is a string optionally embedded into TXR at build time which can be displayed with a command line option. It can help developers who are juggling multiple builds in their workspace to identify what they are running. * Makefile (txr.o, txr-win.o): If a build_id has been defined, then define the TXR_BUILD_ID macro on the command line when compiling these object files. * configure (build_id): New variable. (help) Describe build_id. (gen_config_make): Generate build_id and build_id_exp make variables. * txr.1: Documented --build-id option. * tsr.c (build_id): Conditionally defined global variable. (help): Brief help string for --build-id. (txr_main): Process --build-id option.
* doc: fix in --version option.Kaz Kylheku2021-07-111-1/+2
| | | | | * txr.1: Revise description of --version command line option for grammar and accuracy.
* compiler: disallow trailing slashes in path.Kaz Kylheku2021-07-101-1/+3
| | | | | * stdlib/compiler.tl (open-compile-streams): If in-path end in a path separator character, throw an error.
* doc: finish incomplete sentence about hlet.Kaz Kylheku2021-07-101-1/+7
| | | | | | * txr.1: In a paragraph about the differences between compiled and interpretd behavior, complete a sentence about hlet/hlet* variables. Spotted by Paul A. Patience.
* doc: improve.Paul A. Patience2021-07-102-89/+101
| | | | | | | | | | | | * RELNOTES: Fix minor issues. * txr.1: Fix various grammatical errors, typos and other issues. Notably, use en dashes rather than hyphens for ranges of numbers; replace "exponential notation" with "E notation", which is more commonly used (according to Wikipedia; see https://en.wikipedia.org/wiki/Scientific_notation#E_notation); clarify that with-stream is better than with-resources for opening exactly one stream; and use past tense in the Compatibility Version Values section.
* doc-lookup: ignore BROWSER when empty.Paul A. Patience2021-07-102-11/+12
| | | | | | | | | * stdlib/doc-lookup.tl (open-url): Treat empty BROWSER variable as if it were unset (i.e., ignore it). Otherwise the doc function silently fails rather than falling back to alternative URL-opening methods. * txr.1: Documented.
* New function: add-suffix.Kaz Kylheku2021-07-105-0/+149
| | | | | | | | | | | * stream.c, stream.h (add_suffix): New function. (stream_init): add-suffix intrinsic registered. * tests/018/path.tl: Tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* New functions: trim-short-suffix, trim-long-suffix.Kaz Kylheku2021-07-107-0/+191
| | | | | | | | | | | | | | | * lib.c, lib.h (chk_substrdup): New function. * stream.c, stream.h (trim_short_suffix, trim_long_suffix): New functions. (stream_init): trim-short-suffix and trim-long-suffix intrinsics registered. * tests/018/path.tl: New tests. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* suffix functions: new test cases.Kaz Kylheku2021-07-101-1/+3
| | | | | * tests/018/path.tl: New cases covering dotted name situation, which is not a suffix, but can have a suffix.
* lib: tests for keep-if, remove-if, separate.Kaz Kylheku2021-07-101-0/+42
| | | | * tests/012/seq.tl: New tests.
* lib: new function separate.Paul A. Patience2021-07-095-5/+131
| | | | | | | | | | | | * lib.c (separate): New function. * lib.h (separate): Declared. * eval.c (eval_init): Register separate intrinsic. * txr.1: Documented. * stdlib/doc-syms.tl: Updated.
* compiler: remove case of ad-hoc path catenation.Kaz Kylheku2021-07-091-2/+1
| | | | | * compiler.tl (open-compile-streams): Use path-cat instead of quasiliteral.
* compiler: use short-suffix.Paul A. Patience2021-07-091-15/+10
| | | | | | | | | * stdlib/compiler.tl (open-compile-streams): Replace usage of %file-suff-rx% with a call to short-suffix. Streamline (subjectively) the obtention of ip-nosuff. Replace calls to ends-with with a casequal on the suffix. Actually make use of ip-nosuff. (%file-suff-rx%): Delete (now unused) variable.
* lib: c++ fix.Kaz Kylheku2021-07-091-1/+1
| | | | | | | lib.c (built_in_type): Use i for stepping over the enumeration, because type_t has no postfix ++ operator for i++. The code2type function takes an int, and so no cast is required.
* defstruct: diagnose built-in type being redefined.Kaz Kylheku2021-07-097-9/+25
| | | | | | | | | | | | | | | | | | * eval.c (eval_init): Register built-in-type-p intrinsic. * lib.c (buitin_type_p): Rename to built_in_type_p since the word built-in is hyphenated. The function also tests whether the argument is a COBJ class. (cobj_class_exists): Function removed. * stdlib/doc-syms.tl: Updated. * stdlib/struct.tl (defstruct): Add built-in-type-p check. * struct.c (make_struct_type): Call only built_in_type_p; cobj_class_exists is gone. * txr.1: Document built-in-type-p.
* struct: rework stype_handle change.Kaz Kylheku2021-07-092-29/+34
| | | | | | | | | | | | | | | | | | | | | | | The change which allows stype_handle to recognize struct instances, and obtain their type, has some possibly unwanted ramifications, since the function is widely used. Let's refactor things so that, for now, only the struct_type_name function takes advantage of this flexibility. * struct.c (stype_handle_impl): New static function, copy of stype_handle, but taking an obj_ok Boolean argument to indicate whether an object instance is an acceptable argument, whose type should be fetched. (stype_handle): Now a wrapper around stype_handle_impl passing nil for the obj_ok argument. (stype_handle_obj): New static function. Passes t for the ok_obj argument of stype_handle_impl. (struct_type_name): Call stype_handle_obj instead of stype_handle. (super): Take advantage of stype_handle_obj to reduce code. * txr.1: Update documentation of struct-type-name, and improve that of super.
* subtypep: handle COBJ inheritance.Kaz Kylheku2021-07-092-10/+50
| | | | | | | | | | | | | | | | | | * lib.c (class_from_sym): New static function. (subtypep): Remove special case handling of stream versus stdio-stream. If the two types are not both structures, then check whether they are both cobj classes. If so, check if they are in an inheritance relationship via the cobj_hash. (cobj_populate_hash): Map each symbol to a fixnum integer which gives class handle'position in the cobj_class table. (cobj_class_exists): Style: compare to nil instead of 0. (obj_init): Do not call cobj_populate_hash here, it is far too early: only a couple of COBJ types exist at this point. Moreover, hash_init has not been called so hash_cls and hash_iter_cls still have null symbols. (init): Call obj_populate_hash here, as the last step. * tests/012/type.tl: New file.
* gc: don't mark COBJ cls_sym.Kaz Kylheku2021-07-091-1/+1
| | | | | | * gc.c (mark_obj): We don't need to mark this because it's necessarily a protected symbol handled by prot_sym. Waste of cycles.
* type: disallow structs using built-in type names.Kaz Kylheku2021-07-0830-271/+451
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a big commit motivated by the need to clean up the situation with built-in type symbols, COBJ objects and structs. The struct type system allows struct types to be defined for symbols like regex or str, which are used by built-in or cobj types. This is a bad thing. What is worse, structure instances are COBJ types which identify their type using the COBJ class symbol mechanism. There are places in the C implementation which assume that when a COBJ has a certain class symbol, it is of a certain expected type, which is totally different from and incompatible form a struct instance. User code can define a structure object which will fool that code. There are multiple things going on in this patch. The major theme is that the COBJ representation is changing. Instead of a class symbol, COBJ instances now carry a "struct cobj_class *" pointer. This pointer is obtained by registration via the cobj_register function. All modules must register their class symbols to obtain these class handles, which are then used in cobj() calls for instantiation. The CPTR type was identical to COBJ until now, except for the type tag. This is changing; CPTR objects will keep the old representation with the class symbol. commit 20fdfc6008297001491308849c17498c006fe7b4 Author: Kaz Kylheku <kaz@kylheku.com> Date: Thu Jul 8 19:17:39 2021 -0700 * ffi.h (carray_cls): Declared. * hash.h (hash_cls): Declared. (hash_early_init): Declared. * lib.h (struct cobj_class): New struct. (struct cobj): cls member changing to struct cobj_class *. (struct cptr): New struct, same as previous struct cobj. (union obj): New member cp of type struct cptr, for CPTR. (builtin_type): Declared. (class_check): Declaration moved closer to COBJ-related functions and updated. (cobj_register, cobj_register_super, cobj_class_exists): New functions declared. (cobjclassp, cobj_handle, cobj_ops): Declarations updated. * parser.h (parser_cls): Declared. * rand.h (random_state_cls): Declared. * regex.h (regex_cls): Declared. * stream.h (stream_cls, stdio_stream_cls): Declared. * struct.h (struct_cls): Declared. * tree.h (tree_cls, tree_iter_cls): Declared. * vm.h (vm_desc_cls): Declared. * buf.c (buf_strm, make_buf_stream): Pass stream_cls functions instead of stream_s class symbol. * chksum.c (sha256_ctx_cls, md5_ctx_cls): New static class handles. (sha256_begin, sha256_hash, sha256_end, md5_begin, md5_hash, md5_end): Pass class handles to instead of class symbols. (chksum_init): Initialize class handle variables. * ffi.c (ffi_type_cls, ffi_call_desc_cls, ffi_closure_cls, union_cls): New static class handles. (carray_cls): New global variable. (ffi_type_struct_checked, ffi_type_print_op, ffi_closure_struct_checked, ffi_closure_print_op, make_ffi_type_builtin, make_ffi_type_pointer, make_ffi_type_struct, make_ffi_type_union, make_ffi_type_array, make_ffi_type_enum, ffi_call_desc_checked, ffi_call_desc_print_op, ffi_make_call_desc, ffi_make_closure, carray_struct_checked, carray_print_op, make_carray, cptr_getobj, cptr_out, uni_struct_checked, make_union_common): Pass class handles instead of class symbols. (ffi_init): Initialize class handle variables. * filter.c (regex_from_trie): Use hash_cls class handle instead of hash_s. * gc.c (mark_obj): Split COBJ and CPTR cases since the representation is different. * hash.c (hash_cls, hash_iter_cls): New class handles. (make_similar_hash, copy_hash, gethash_c, gethash_e, remhash, clearhash, hash_count, get_hash_userdata, set_hash_userdata, hashp, hash_iter_init, hash_begin, hash_next, hash_peek, hash_reset, hash_reset, hash_uni, hash_diff, hash_symdiff, hash_isec): Pass class handles instead of class symbols. (hash_early_init): New function. (hash_init): Set the class symbols in the class handles that were created in hash_early_init at a time when these symbols did not exist. * lib.c (nelem): New macro. (cobj_class): New static array. (cobj_ptr): New static pointer. (cobj_hash): New static hash. (seq_iter_cls): New static class handle. (builtin_type_p): New function. (typeof): Struct instances now all carry the same symbol, struct, as their COBJ class symbol. To get their type, we must call struct_type_name. (subtypep): Rearrangement of two cases: let's make the reflexive case first. Adjust code for different location of COBJ class symbol. (seq_iter_init_with_info, seq_begin, seq_next, seq_reset, iter_begin, iter_more, iter_item, iter_step, iter_reset, make_like, list_collect, do_generic_funcall): Use class handles instead of class symbols. (class_check, cobj, cobjclassp, cobj_handle, cobj_ops): Take class handle argument instead of class symbol. (cobj_register, cobj_register_super, cobj_class_exists): New functions. (cobj_populate_hash): New static function. (cobj_print_op): Adjust for different location of class (cptr_print_op, cptr_typed, cptr_type, cptr_handle, cptr_get): cptr functions now refer to obj->cp rather than obj->co. (copy, length, sub, ref, refset, replace, dwim_set, dwim_del, obj_print): Use class handles for various COBJ types rather than class symbols. (obj_init): gc-protect cobj_hash. Initialize seq_iter_cls class symbol and cobj_hash. Populate cobj_hash as the last initialization step. (init): Call hash_early_init immediately after gc_init. diff --git a/lib.c b/lib.c * match.c (do_match_line): Refer to regex_cls class handle instead of regex_s.. * parser.c (parser_cls): New global class handle. (parse, parser_get_impl, lisp_parse_impl, txr_parse, parser_errors): Use class handles instead of class symbols. (parse_init): Initialize parser_cls. * rand.c (random_state_cls): New global class handle. (make_state, random_state_p, make_random_state, random_state_get_vec, random_fixnum, random_float, random): Use class handles instead of class symbols. (rand_init): Initialize random_state_cls. * regex.c (regex_cls): New global class handle. (chset_cls): New static class handle. (reg_compile_csets, reg_derivative, regex_compile, regexp, regex_source, regex_print, regex_run, regex_machine_init): Use class handles instead of class symbols. (regex_init): Initialize regex_cls and chset_cls. * socket.c (make_dgram_sock_stream): Use stream_cls class symbol instead of stream_s. * stream.c (stream_cls, stdio_stream_cls): New class handles. (make_null_stream, stdio_get_fd, make_stdio_stream_common, stream_fd, sock_family, sock_type, sock_peer, sock_set_peer, make_dir_stream, make_string_input_stream, make_string_byte_input_stream, make_strlist_input_stream, make_string_output_stream, make_strlist_output_stream, get_list_from_stream, make_catenated_stream, make_delegate_stream, make_delegate_stream, stream_set_prop, stream_get_prop, close_stream, get_error, get_error_str, clear_error, get_line, get_char, get_byte, get_bytes, unget_char, unget_byte, put_buf, fill_buf, fill_buf_adjust, get_line_as_buf, format, put_string, put_char, put_byte, flush_stream, seek_stream, truncate_stream, get_indent_mode, test_set_indent_mode, test_neq_set_indent_mode, set_indent_mode, get_indent, set_indent, inc_indent, width_check, force_break, set_max_length, set_max_depth): Use class handle instead of symbol. (stream_init): Initialize stream_cls and stdio_stream_cls. * struct.c (struct_type_cls, struct_cls): New class handles. (struct_init): Initialize struct_type_cls and struct_cls. (struct_handle): Static function moved to avoid forward declaration. (stype_handle): Refer to struct_type_cls class handle instead of struct_type_s symbol. Handle instance objects in addition to types. (make_struct_type): Throw error if a built-in type is being defined as a struct type. Refer to class handle instead of class symbol. (find_struct_type, allocate_struct, make_struct_impl, make_lazy_struct, copy_struct): Refer to class handle instead of class symbol. * strudel.c (make_struct_delegate_stream): Refer to stream_cls class handle instead of stream_s symbol. * sysif.c (dir_cls): New class handle. (poll_wrap): Use typep instead of subtypep, eliminating access to class symbol. (opendir_wrap, closedir_wrap, readdir_wrap): Use class handles instead of class symbols. (sysif_init): Initialize dir_cls. * syslog.c (make_syslog_stream): Refer to stream_cls class handle instead of stream_s symbol. * tree.c (tree_cls, tree_iter_cls): New class handles. (tree_insert_node, tree_lookup_node, tree_delete_node, tree_root, tree_equal_op, tree, copy_search_tree, make_similar_tree, treep, tree_begin, copy_tree_iter, replace_tree_iter, tree_reset, tree_next, tree_peek, tree_clear): Use class handle instead of class symbol. (tree_init): Initialize tree_cls and tree_iter_cls. * unwind.c (sys_cont_cls): New static class handle. (revive_cont, capture_cont): Use class handle instead of class symbol. (uw_late_init): Initialize sys_cont_cls. * vm.c (vm_desc_cls): New global class handle. (vm_closure_cls): New static class handle. (vm_desc_struct, vm_make_desc, vm_closure_struct, vm_make_closure, vm_copy_closure): Use class handle instead of class symbol. (vm_init): Initialize vm_desc_cls and vm_closure_cls.