summaryrefslogtreecommitdiffstats
path: root/lisplib.c
Commit message (Collapse)AuthorAgeFilesLines
* The stdlib variable gets a trailing slash.Kaz Kylheku2016-06-051-14/+14
| | | | | | | | | | | | | | | | | | | * txr.c (sysroot_init): Add slash to stdlib_path. (sysroot_compat_fixup): Replace user-visible stdlib variable with a path that doesn't have a slash, if compatibility is 143 or lower. (compat): Call sysroot_compat_fixup. * lisplib.c (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): Remove slash from format string since the directory includes it. * txr.1: Added note under stdlib about the slash, and also an entry COMPATIBILITY.
* Adding termios support.Kaz Kylheku2016-05-181-1/+27
| | | | | | | | | | | | | | | | * Makefile (termios.o): New object file. * lib.c (init): Call termios_init. * lisplib.c (termios_set_entries, termios_instantiate): New functions. (lisplib_init): Register new functions in autoload table. * share/txr/stdlib/termios.tl: New file. * termios.c, termios.h: New files. * txr.1: Documented termios.
* Somew new path access testing functions.Kaz Kylheku2016-05-041-1/+4
| | | | | | | | | | | | | | * lisplib.c (path_test_set_entries): New elements in the list for path-readable-to-me-p, path-read-writable-to-me-p, and path-strictly-private-to-me-p. * share/txr/stdlib/path-test.pl (sys:path-access): Test bitwise combinations of permissions, so read+write can be tested in one call. (path-readable-to-me-p, path-read-writable-to-me-p, path-strictly-private-to-me-p): New functions. * txr.1: Documented.
* Macros obtain* and obtain*-block.Kaz Kylheku2016-04-151-0/+1
| | | | | | | | | | * lisplib.c (yield_set_entries): Add obtain* and obtain*-block to autoload list. * share/txr/stdlib/yield.tl (obtain*, obtain*-block): New macros. * txr.1: Documented.
* Make open_socket static and register in socket.c.Kaz Kylheku2016-04-141-1/+1
| | | | | | | | | | | | | | * lisplib.c (sock_set_entries): Add auto-load entry for open-socket. * socket.c (open_socket): Change to static. (sock_load_init): Register open-socket intrinsic here rather than in stream.c. * stream.c (stream_init): Remove registration of open-socket intrinsic. * stream.h (open_socket): Declaration removed.
* New open-socket-pair function.Kaz Kylheku2016-04-141-0/+1
| | | | | | | | | | | * lisplib.c (sock_set_entries): Add open-socket-pair to autoload list. * socket.c (sock_mark_connected, socketpair_wrap): New static functions. (sock_load_init): Register open-socket-pair intrinsic. * txr.1: Documented.
* lib-version variable doesn't autoloadKaz Kylheku2016-04-121-1/+1
| | | | | * lisplib.c (ver_set_entries): Add lib-version to autoload list.
* New macro: lset.Kaz Kylheku2016-03-281-1/+1
| | | | | | | | | * lisplib.c (place_set_entries): Added "lset" to autoload list. * share/txr/stdlib/place.tl (lset): New macro. * txr.1: Documented lset.
* Functions for address prefixes to slash notation.Kaz Kylheku2016-02-291-0/+1
| | | | | | | | | | | * lisplib.c (sock_set_entries): Autload entries for str-inaddr-net and str-in6addr-net. * share/txr/stdlib/socket.tl (str-inaddr-net, str-in6addr-net): New functions. * txr.1: Documented str-inaddr, str-in6-addr, str-inaddr-net and str-in6addr-net.
* IP address to string functions.Kaz Kylheku2016-02-291-0/+1
| | | | | | | | * lisplib.c (sock_set_entries): Add str-inaddr and str-in6addr to list of autoload identifiers. * share/txr/stdlib/socket.tl (str-inaddr, str-in6addr): New functions.
* Adding socket support: unix, ipv4, ipv6.Kaz Kylheku2016-02-261-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * socket.c, socket.h: New files. * Makefile: include new socket.o among objects if have_objects variable is defined to 'y'. * configure (have_sockets): New variable. New configure test for socket-related functionality. (HAVE_SOCKETS, HAVE_GETADDRINFO): New configuration preprocessor symbols. Also, reordering the shell probing so that /usr/xpg4/bin/sh is the last fallback. On Solaris, it chokes on some code that is needed for Solaris. * lisplib.c (sock_set_entries, sock_instantiate): New static functions. (lisplib_init): Register new functions as autoload hooks. * share/txr/stdlib/socket.tl: New file. * stream.c (socket_error_s): New symbol variable. (struct stdio_handle): New members, family and type, helping stdio streams represent sockets too. (stdio_stream_mark): Mark new members of struct stdio_handle. (make_stdio_stream_common): Initialize new members. (make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): New functions. (stream_init): Initialize socket_error_s variable. Register sock-family, sock-type and open-socket intrinsic functions. Register socket-error subtype. * stream.h (socket_error_s, make_sock_stream, stream_fd, sock_family, sock_type, open_socket, open_sockfd): Declared.
* Header file cleanup.Kaz Kylheku2016-01-221-1/+0
| | | | | | | * arith.c, cadr.c, debug.c, eval.c, filter.c, gencadr.txr, glob.c, hash.c, linenoise/linenoise.c, lisplib.c, match.c, parser.c, rand.c, regex.c, signal.c, stream.c, struct.c, sysif.c, syslog.c, txr.c, unwind.c, utf8.c: Remove unncessary header files.
* Copyright year bump.Kaz Kylheku2015-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * LICENSE, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/cadr.tl, share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Add 2016 copyright. * linenoise/LICENSE, linenoise/linenoise.c, linenoise/linenoise.h: Bump one principal author's copyright from 2014 to 2015. The code is based on a snapshot of 2015 upstream work.
* Adding with-slots macro.Kaz Kylheku2015-12-271-0/+1
| | | | | | | | | * lisplib.c (place_set_entries): Add with-slots to autoload name list. * share/txr/stdlib/struct.tl (with-slots): New macro. * txr.1: Documented.
* New condlet macro; small change to iflet/whenlet.Kaz Kylheku2015-12-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | * eval.c (me_iflet_whenlet): Allow the test form to be an atomic expression instead of bindings. This allows iflet to be used as the sole target construct of condlet, while allowing condlet to have a fallback clause with t. It also means that an empty list of bindings is allowed (since it is the atom nil). * lisplib.c (ifa_set_entries): Add "condlet" to the autoload names for the ifa module. That's where we are adding condlet. * share/txr/stdlib/ifa.tl (sys:if-to-cond): New macro expander helper function, generalizing the writing cond-like macros based on if-like operators. (conda): Rewritten using sys:if-to-cond. (condlet): New macro. * txr.1: Documented change in iflet/whenlet. Documented condlet.
* Fix useless use of if3.Kaz Kylheku2015-12-181-2/+2
| | | | * lisplib.c (lisplib_try_load): if3(a, b, nil) -> if2(a, b).
* New macro define-accessor.Kaz Kylheku2015-11-251-1/+1
| | | | | | | | | | | * lisplib.c (place_set_entries): New entry to trigger autoloading for define-accessor. * share/txr/stdlib/place.tl (sys:register-simple-accessor): New function. (define-accessor): New macro. * txr.1: Documented define-accessor.
* New uslot function and usl macro.Kaz Kylheku2015-11-201-1/+1
| | | | | | | | | | | | | | * struct.c (struct_init): Register uslot intrinsic function. (uslot_fun): New static function. (uslot): New function. * struct.h (uslot): Declared. * share/txr/stdlib/struct.tl (usl): New macro. * lisplib.c (struct_set_entries): Add usl macro. * txr.1: Documented uslot and usl.
* Bugfix: missing macros in autoload.Kaz Kylheku2015-11-141-1/+2
| | | | | * lisplib.c (struct_set_entries): Bugfix: missing meth, umeth and defmeth.
* Define suspend operator.Kaz Kylheku2015-10-301-0/+1
| | | | | | | | | | * lisplib.c (yield_set_entries): Added "suspend" to end of name. * share/txr/stdlib/yield.tl (suspend): New macro. * txr.1: Documented suspend. Replaced subtly incorect shift/reset implementation example with suspend implementation.
* Fix with-hash-table-iter typo.Kaz Kylheku2015-10-281-1/+1
| | | | | | | * lisplib.c (hash_set_entries): Change with-hash-table-iter to with-hash-iter. * txr.1: Likewise.
* Add obtain/yield macros interface to continuations.Kaz Kylheku2015-10-281-0/+16
| | | | | | | | | | | * lisplib.c (yield_set_entries, yield_instantiate): New static functions. (dlt_register): Registered new functions. * share/txr/stdlib/yield.tl: New file. * txr.1: Documented obtain, yield-from, obtain-block and yield.
* Adding typecase macro.Kaz Kylheku2015-10-141-0/+16
| | | | | | | | | | * lisplib.c (type_set_entries, type_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/type.tl: New file, providing typecase * txr.1: Documented typecase.
* New way of handling exceptions without unwinding.Kaz Kylheku2015-10-141-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * eval.c (handler_bind_s): New symbol variable. (op_handler_bind): New static function. (do_expand): Traverse handler-bind forms. (eval_init): Initialize handler_bind_s variable and register handler-bind operator. * lisplib.c (except_set_entries, except_instantiate): New functions. (lisplib_init): Register new functions in dl_table. * parser.c (intr_s): New symbol variable. (repl_intr): Throw exception of type intr, rather than error. This way we can interrupt accidental exception handling loops involving exceptions derived from error. (parse_init): Initialize intr_s. * share/txr/stdlib/except.tl: New file, defines handle macro. * unwind.c (uw_push_handler): New function. (invoke_handler): New static function. (uw_throw): Search loop looks for and processes handlers in addition to catches. * unwind.h (uw_frtype_t): New enum member, UW_HANDLE. (struct uw_catch): Move member visible so it is in the same position as in struct uw_handler. (struct uw_handler): New struct type. (union uw_frame): New member ha of type struct uw_handler. (uw_push_handler): Function declared. * txr.1: Added introductory paragraphs to Exception Handling section. Documented handler-bind and handle. Some minor errors corrected.
* Hash table iterators exposed, with new macro.Kaz Kylheku2015-10-111-0/+15
| | | | | | | | | | | * eval.c (eval_init): Register hash-begin and hash-next intrinsics. * lisplib.c (hash_set_entries, hash_instantiate): New static functions. (lisplib_init): Register new tables in dl_table. * share/txr/stdlib/hash.tl: New file. * txr.1: Document with-hash-iter macro.
* New macro: with-objects.Kaz Kylheku2015-10-101-1/+5
| | | | | | | | | | | * lisplib.c (with_resources_set_entries): "with-objects" added to name table. * share/txr/stdlib/with-resources.tl (with-objects): New macro. * txr.1: Documented with-objects. Added note to :fini specifier of defstruct pointing to call-finalizers and with-objects.
* Various stream-related with- macros introduced.Kaz Kylheku2015-10-081-0/+22
| | | | | | | | | | * lisplib.c (with_stream_set_entries, with_stream_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/with-stream.tl: New file. * txr.1: Documented new macros.
* New function path-private-to-me.Kaz Kylheku2015-09-171-1/+1
| | | | | | | | | * lisplib.c (path_test_set_entries: "path-private-to-me-p" addred to name array. * share/txr/stdlib/path-test.tl (path-private-to-me-p): New function. * txr.1: Documented path-private-to-me.
* Introducing structs.Kaz Kylheku2015-09-021-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * args.c (args_cat_zap): New function. * args.h: (args_cat_zap): Declared. * eval.c (struct_lit_s): New symbol variable. (eval_init): Initialize struct_lit_s. * eval.h (struct_lit_s): Declared. * gc.c (finalize): If a symbol has a struct slot hash attached to it, we must free it when the symbol is reclaimed. * lib.c (make_sym): Initialize symbol's slot_cache pointer to null. (copy): Copy structure objects. (init): Call struct_init to initialize struct module. * lib.h (SLOT_CACHE_SIZE): New preprocessor symbol (slot_cache_line_t, slot_cache_t): New typedefs. (struct sym): New member, slot_cache. * lisplib.c (struct_set_entries, struct_instantiate): New static functions. (liplib_init): Register new functions in dl_table. parser.y (HASH_S): New terminal symbol. (struct): New grammar rule. (n_expr): Derive struct. (yybadtoken): Map HASH_S to #S string. parser.l (grammar): Recognize #S and return HASH_S token. share/txr/stdlib/place.tl (slot): New defplace. share/txr/stdlib/struct.tl: New file. struct.c: New file. struct.h: New file. * Makefile (OBJS): Adding struct.o.
* Suppress debug stepping into auto-loaded library code.Kaz Kylheku2015-08-061-1/+7
| | | | | | | | | | | | | | | | | | | | | * debug.c (debug_set_state, debug_restore_state): New functions. * debug.h (debug_state_t): New type. (debug_set_state, debug_restore_state): Declared, and defined as dummy macros in non-debug-support build. * lisplib.c (opt_dbg_autoload): New global variable. (lisplib_try_load): Disable or enable debugging around library loading based on opt_dbg_autoload option. * lisplib.h (opt_dbg_autoload): Declared. * txr.c (help): List --debug-autoload option. (no_dbg_support): New static function to avoid repeated code. (txr_main): Add debugger option. Change duplicate no debug support error messages into calls to no_dbg_support. * txr.1: Document --debug-autoload
* New filesystem object testing functions.Kaz Kylheku2015-08-051-0/+25
| | | | | | | | | | * lisplib.c (path_test_set_entries, path_test_instantiate): New static functions. (dlt_register): Registered new functions to dl_table. * txr.1: Documented new functions. * share/txr/stdlib/path-test.tl: New file.
* Adding with-resources macro.Kaz Kylheku2015-07-231-0/+15
| | | | | | | | | | * share/txr/stdlib/with-resources.tl: New file. * lisplib.c (with_resource_set_entries, with_resources_instantiate): New static functions. (lisplib_init): Register new functions under dlt_register. * txr.1: Document with-resources.
* * lisplib.c (place_set_entries): Add *place-macro* andKaz Kylheku2015-07-221-2/+2
| | | | | | | | | | | | | | define-place-macro to list of names. * share/txr/stdlib/place.tl (*place-macro*): New global hash. (sys:tigger-load, sys:pl-expand): New functions. (call-update-expander, call-clobber-expander, call-delete-expander): Recognize and expand place macros. (define-place-macro): New macro. (first, rest): Places redefined using define-place-macro, replacing the old hack of copying the expanders from one table entry to another. * txr.1: Documented place macros.
* Implementing caar, cadr, cdar and friends.Kaz Kylheku2015-07-211-5/+5
| | | | | | | | | | | | | | | | | | | | * lib.c (init): Call cadr_init. * lisplib.c (dl_table, set_dlt_entries, dlt_register): Externalize. * lisplib.h (dl_table, set_dlt_entries, dlt_register): Declared. * Makefile (OBJS): Add cadr.o. * cadr.c: New file. * cadr.h: New file. * gencadr.txr: New file. * share/txr/stdlib/cadr.tl: New file. * txr.1: Document cadr accessors.
* * share/txr/stdlib/place.tl (place-form-p): New function.Kaz Kylheku2015-07-121-0/+1
| | | | * lisplib.c (place_set_entries): Add place-form-p to list of names.
* Let's have placelet and placelet*.Kaz Kylheku2015-07-111-1/+1
| | | | | | | | * share/txr/stdlib/place.tl (placelet*): New macro. * lisplib.c (place_set_entries): Add placelet* to list of names. * txr.1: Updated to document placelet* and fix mistakes.
* New placelet macro.Kaz Kylheku2015-07-101-0/+1
| | | | | | | | | | | | | | * lisplib.c (place_set_entries): Add placelet to list of names. * share/txr/stdlib/place.tl (sys:placelet1, placelet): New macros. (defplace dwim): Do not retrieve the place's value into a local variable and have the getter expand to that variable. Rather, have the getter retrieve the value. A getter that refers to a cached copy breaks the semantics of placelet, and any place operator which can evaluate the location after it is stored. * txr.1: Documented placelet.
* Bugfix: define-modify-macro not registered for auto-loading.Kaz Kylheku2015-08-081-1/+1
| | | | | * lisplib.c (place_set_entries): Add define-modify-macro to list of names.
* * lisplib.c (ifa_set_entries): Add conda.Kaz Kylheku2015-06-211-1/+1
| | | | | | | | * share/txr/stdlib/ifa.tl (conda): New macro. * tests/012/ifa.tl: Adding test for conda. * txr.1: Documenting conda.
* Remove places.h generation hack.Kaz Kylheku2015-06-201-3/+2
| | | | | | | | | | | | | | * Makefile (GEN_HDRS, LISP_TO_C_STRING): Variables removed. (%.h: %.tl): Rule removed. The place.h header is no longer generated from place.tl. * lisplib.c (place_instantiate): Load place.tl from stdlib directory, rather than obtaining it from a string literal in generated header place.h. * place.tl: Moved to share/txr/stdlib directory. * genvim.txr: Refer to place.tl in stdlib.
* Library .txr files become .tl and are autoloaded.Kaz Kylheku2015-06-181-0/+30
| | | | | | | | | | | | | | | | | * lisplib.c (ver_set_entries, ver_instantiate, txr_case_set_entries, txr_case_instantiate): New static functions. (lisplib_init): Register new functions. * share/txr/stdlib/txr-case.txr: Reduced to a load for the corresponding .tl file, retained for backward compatibility. * share/txr/stdlib/ver.txr: Likewise. * share/txr/stdlib/txr-case.tl: New file, based on previous contents of corresponding .txr file. * share/txr/stdlib/ver.tl: Likewise.
* Adding anaphoric ifa macro.Kaz Kylheku2015-06-171-0/+16
| | | | | | | | | | | | | | | | | | | | * Makefile (install): Install .tl files present in stdlib directory. (INSTALL): Handle argument 2 being a list. * eval.c (load): New function. * eval.h (load): Declared. * lisplib.c (ifa_set_entries, ifa_instantiate): New functions to lazily load ifa.tl. (lisplib_init): Register new functions. * txr.c (stdlib_path): New variable. (sysroot_init): Store the stdlib path in stdlib_path. * txr.h (stdlib_path): Declared. * share/txr/stdlib/ifa.tl: New file.
* Refactoring of lisplib.cKaz Kylheku2015-06-171-8/+26
| | | | | | | | | | | * lisplib.c (set_dlt_entries): New static function. (set_place_dlt_entries): Renamed to place_set_entries. Uses set_dlt_entries as subroutine. (place_instantiate): Argument changes from table to function, which is invoked to null out the hash entries. (dlt_register): New static function. (lisplib_init): Use dlt_register to register dynamic loading of places_tl.
* Adding pushnew.Kaz Kylheku2015-05-221-1/+1
| | | | | | * place.tl (pushnew): New macro. * lisplib.c (set_place_dlt_entries): Add pushnew.
* Represent place.tl more compactly in image.Kaz Kylheku2015-05-191-1/+1
| | | | | | | | | The contents of place.tl are now stored as a UTF-8 ordinary literal instead of a wide char literal. * Makefile (LISP_TO_C_STRING): Generate plain literal. * lisplib.c: Convert plain literal to string.
* * place.tl (define-modify-macro): New macro.Kaz Kylheku2015-05-131-0/+1
| | | | * lisplib.c (set_place_dlt_entries): Add define-modify-macro.
* Adding pset operator.Kaz Kylheku2015-05-091-1/+1
| | | | | | * place.tl (pset): New macro. * lisplib.c (set_place_dlt_entries): Add pset.
* * Makefile (LISP_TO_C_STRING): Strip comments, but not comment lines,Kaz Kylheku2015-05-071-1/+2
| | | | | | | | | | | | | | | | | | so line numbers don't change. * eval.c (eval_init): Fix registrations of lisp-parse and read. * lisplib.c (place_instantiate): Give name to parsed string stream using new lisp_parse argument. * parser.c (lisp_parse): Takes new argument to override name. * parser.h (lisp_parse): Declaration updated. * txr.c (txr_main): Call lisp_parse with four args, defaulting the new one. * txr.1: Documented new argument.
* New macro-based framework for assignment places.Kaz Kylheku2015-05-061-0/+83
The operators set, inc, dec, pop and others are now macros which generate code, rather than built-in special forms that use "C magic". Moreover, new such macros are easy to write, and several new ones are already available. Moreover, new kinds of assignable places are easy to create. * place.tl: New file. * lisplib.c, lisplib.h: New files. * Makefile (OBJS): New target, lisplib.o. (GEN_HDRS): New variable. (LISP_TO_C_STRING): New recipe macro, with rule. (clean): Remove generated headers named in $(GEN_HDRS). * eval.c (dec_s, push_s, pop_s, flip_s, del_s): Variables removed. (setq_s): New variable. (lookup_var, lokup_sym_lisp_1, lookup_var_l, lookup_fun, lookup_mac, lookup_symac, lookup_symac_lisp1): Trigger the delayed loading of libraries for undefined global symbols, and re-try the lookup. (op_modplace, dwim_loc, force_l): Static functions removed. (op_setq): New static function. (eval_init): Initialize setq_s; remove initializations of removed variables; remove registrations for op_modplace; add registration for sys:setq, sys:rplaca, sys:rplacd, sys:dwim-set and sys:dwim-del intrinsics. Call lisplib_init to initialize the dynamic library loading module. * lib.c (sys_rplaca, sys_rplacd): New functions, differing in return value from rplaca and rplacd. (ref, refset): Handle hash table. (dwim_set, dwim_del): New functions. * lib.h (sys_rplaca, sys_rplacd, dwim_set, dwim_del): Declared. * genvim.txr: Include place.tl in scan. * tests/010/seq.txr: The del operator test case no longer throws at run-time but at macro-expansion time, so the test case is simply removed. * tests/010/seq.expected: Updated output. * tests/011/macros-2.txr: Reset *gensym-counter* to zero, because the textual output of the test case includes gensyms, whose numberings fluctuate with the content of the new Lisp library material. * tests/011/macros-2.expected: Updated output.