summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
* copy: call copy-fun for functions.Kaz Kylheku2018-11-171-0/+6
| | | | | | * lib.c (copy): Handle FUN type through copy_fun. * txr.1: Documented.
* compile: handle functions that have environments.Kaz Kylheku2018-11-131-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this patch, the compile function can handle interpreted function objects that have captured environments. For instance, if the following expression is evaluated (let ((counter 0)) (labels ((bm () (bump)) (bump () (inc counter))) (lambda () (bm)))) then a function object emerges. We can now feed this function object to the compile function; the environment will now be handled. Of course, the above expression is already compileable; compile-toplevel handles it and so does the file compiler. This patch allows the expression to be interpreted and then the function object to be compiled, without access to the surrounding expression. The compiled function will contain a compiled version of the environment, carrying compiled versions of the captured variables and their contents. * eval.c (env_vbindings, env_fbindings, env_next): New static functions. (eval_init): Register env-vbinding, env-fbindings and env-next intrinsics. * share/txr/stdlib/compiler.tl (sys:env-to-let): New function. (usr:compile): Wrap the interpreted lambda terms with let bindings carefully reconstructed from their captured environments. * txr.1: Documented new intrinsic functions.
* copy-fun: duplicate a function, with own environment.Kaz Kylheku2018-11-131-0/+36
| | | | | | | | | | | | | | | | | * eval.c (deep_copy_env): New function. (eval_init): Register copy-fun intrinsic. * eval.h (deep_copy_env): Declared. * lib.c (copy_fun): New function. * lib.h (copy_fun): Declared. * vm.c (vm_copy_closure): New function. * vm.h (vm_copy_closure): Declared. * txr.1: Documented copy-fun.
* doc: corrections under Referencing DotKaz Kylheku2018-11-111-6/+9
| | | | | * txr.1: Don't start sentence with And. Revise and correct description of associativity of referencing dot.
* doc: changes to introKaz Kylheku2018-11-111-27/+39
| | | | | | * txr.1: Substantially revising introductory paragraphs. Mentioning compiling and stand-alone application deployment. Mention licensing freedom.
* doc: listener suspend doesn't "depend" on job controlKaz Kylheku2018-11-111-2/+6
| | | | | | | * txr.1: Revise wording implying that the Ctrl-Z suspend depends on POSIX job control. Job control is required for it to allow TXR to be foregrounded after it suspends. That is not our problem.
* doc: listener: remove irrelvant historic notesKaz Kylheku2018-11-111-9/+2
| | | | | | * txr.1: In descriptions of multi-line mode, remove notes about behavior changes between TXR 178 and 179. This doesn't affect TXR program and is probably of no interest to anyone.
* doc: fixes under Null Hack description.Kaz Kylheku2018-11-111-9/+11
| | | | | * txr.1: Fix awkward wording about env's dispatch of txr, and references to wrong user name in examples.
* Version 201.Kaz Kylheku2018-11-071-3/+3
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: load: document hash bang treatment.Kaz Kylheku2018-11-061-0/+8
| | | | | * txr.1: Document that the load function ignores the hash bang line in both compiled and source files.
* doc: split/split*: formatting of syntaxKaz Kylheku2018-11-061-2/+2
| | | | * txr.1: Fix funny formatting.
* compiler: bugfix: handle defpackage and such properly.Kaz Kylheku2018-11-051-0/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that the file compiler is emitting one big form that contains all of the compiled top-level forms. For obvious reasons, this doesn't work when that form contains symbols that are in a package which is defined by one of those forms; the compiled file will not load due to qualified symbols referencing a nonexistent package. The solution is to break up that big form when it contains forms that manipulate the package system in ways that possibly affect the read time of subsequent forms. * lib.c (delete_package): Use a non-destructive deletion on the *package-alist*, because we are going to be referring to this variable in the compiler to detect whether the list of packages has changed. * share/txr/stdlib/compiler.tl (%package-manip%): New global variable. This is a list of functions that manipulate the package system in suspicious ways. (user:compile-file): When compiling a form which is a call to any of the suspicious functions, add a :fence symbol into the compiled form list. Also do this if the evaluation of the compiled form modifies the *package-alist* variable. When emitting the list of forms into the output file, remove the :fence symbols and break it up into multiple lists along these fence boundaries. * txr.1: Documented the degenerate situation that can arise.
* Version 200.txr-200Kaz Kylheku2018-11-051-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* buffers: implement copy-buf.Kaz Kylheku2018-11-041-0/+22
| | | | | | | | | | | * buf.c (copy_buf): New function. (buf_init): Register copy-buf intrinsic. * buf.h (copy_buf): Declared. * lib.c (copy): Handle BUF via copy_buf. * txr.1: Documented.
* compiler: optimize dwim.Kaz Kylheku2018-11-041-4/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * share/txr/stdlib/asm.tl (op-getf): Rename to op-oldgetf. This opcode becomes obsolescent. (op-getf): New opcode. * share/txr/stdlib/compiler.tl (assumed-fun): New global variable. (compiler comp-fun): Use the new getf instruction which takes a function table index instead of a data table index. (compiler comp-lisp1-value): Don't use getl1 opcode any more for dynamic lisp1-style lookup. Instead, we bake the behavior at compile time perform a function lookup if the symbol is completely unbound, a variable lookup if it is bound to a variable (where we decide at compile tie whether it is lexical or dynamic) or else a function if a function binding exists at compile time. Also, if we assume that an unbound symbol is a function, put it on the assumed-fun list. (compiler comp-dwim): If the first argument is a symbol with no lexical binding, and is not bound as a variable, then treat it as a function by transforming the form into a function call form with that symbol in the car position. Put the symbol on the assumed-fun list. (compiler-emit-warnings): New function. (with-compilation-unit): Call compiler-emit-warnings when bailing out of most enclosing compilation unit. (%tlo-ver%): Bump compiled file version to 4, since we added an opcode. * vm.c (vm_execute): Follow rename of GETF to OLDGETF. Implement the new GETF. * parser.c (read_file_common): Extend version range to allow version 4 compiled files. * txr.1: Documented everything.
* The code expander becomes a public API.Kaz Kylheku2018-11-021-0/+291
| | | | | | | | | | | | | | | | | | | | | | | The functions sys:expand, sys:expand* and sys:expand-with-free-refs are now in the usr package and documented for public use. * eval.c (eval_init): Move registrations of the symbools expand, expand* and expand-with-free-refs from the system package to the user package. * share/txr/stdlib/awk.tl (sys:awk-mac-let, awk): Uses of sys:expand drop the sys: prefix. * share/txr/stdlib/op.tl (sys:op-alpha-rename): Likewise. * share/txr/stdlib/place.tl (call-upudate-expander, call-clobber-expander, call-delete-expander, sys:placelet-1): Likewise. * tests/011/macros-2.txr, tests/012/struct.tl: Likewise. * txr.1: Documented expand, expand* and expand-with-free-refs.
* doc: lexical-fun-p: mistake in code example.Kaz Kylheku2018-11-021-2/+2
| | | | * txr.1: Fix misnamed references to macro parameter.
* Hide deprecated, undocumented variables.Kaz Kylheku2018-10-301-0/+4
| | | | | | | | | | * arith.c (arith_init): Do not define *flo-dig*, *flo-max*, *flo-min*, *flo-epsilon*, *pi* and *e* unless compatibility with TXR 199 or earlier is requested. * txr.c (txr_main): Likewise for *self-path*. * txr.1: Compat note added.
* doc: correction under Object TypeKaz Kylheku2018-10-301-1/+1
| | | | | | * txr.1: Square brackets in the graph indicate a categorization node that is invisible to programs, not visible.
* Version 199.txr-199Kaz Kylheku2018-10-281-2/+2
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* doc: *rec-source-loc* bad heading formattingKaz Kylheku2018-10-281-1/+1
| | | | * txr.1: Fix missing @ for code font.
* doc: new section: Compiled File Compatibility.Kaz Kylheku2018-10-271-0/+54
| | | | | | | * txr.1: TXR doesn't guarantee backwards compatibility for handling compiled files, as it does for most aspects of its operation. This has to documented in its own section. Also adding a paragraph to COMPATIBILITY to discuss this.
* doc: document compile-file and load-time interaction.Kaz Kylheku2018-10-271-0/+18
| | | | | * txr.1: Document that compile-file evaluates load-time forms during compilation unless compile-only is used.
* doc: add Compilation Library section header.Kaz Kylheku2018-10-271-0/+2
| | | | | | | | * txr.1: We need a SS section for the compilation functions, otherwise they appear to be children of the preceding "Treatment of the Hash Bang Line" section. An alternative would have been to promote them to a higher section level with .coSS instead of .coNP.
* doc: return value of list-builder methods.Kaz Kylheku2018-10-251-0/+14
| | | | | | * txr.1: Document that the list-builder methods which add to the list have unspecified return values, and that the local functions set up by the build macro are the same way.
* doc: no such thing as define-parameter-macro.Kaz Kylheku2018-10-161-1/+1
| | | | | | * txr.1: Replace reference to the nonexistent define-parameter-macro with the correct define-param-expander.
* doc: shorten some POSIX awk examples.Kaz Kylheku2018-10-141-2/+2
| | | | | | * txr.1: Remove unnecessary test for the existence of a field, since the find function accepts nil. Use len instead of length.
* doc: use nequal.Kaz Kylheku2018-10-141-2/+2
| | | | | * txr.1: shorten some examples by replacing (not (equal ...)) with (nequal ...).
* New function: signum.Kaz Kylheku2018-08-071-0/+25
| | | | | | | arith.c (signum): New function. (arith_init): signum intrinsic registered. * txr.1: Documented.
* doc: option processing fixes.Kaz Kylheku2018-08-021-2/+3
| | | | | * txr.1: Wording change in introductory paragraph. Error in description of Boolean options.
* feature: support for floating-point rounding control.Kaz Kylheku2018-07-261-0/+80
| | | | | | | | | | | | | | | * arith.c (flo_get_round_mode, flo_set_round_mode): New functions. (arith_init): Register global lexical variables flo-near, flo-down, flo-up and flo-zero. Register flo-get-round-mode and flo-set-round-mode intrinsic functions. * configure: Test for fesetround and fegetround variables, and the associated constants, prpoducing a HAVE_ROUNDING_CTL_H variable in config.h. * txr.1: Documented new variables and functions.
* doc: updates regarding top-level form expansion order.Kaz Kylheku2018-07-231-2/+99
| | | | | | * txr.1: The descriptions of eval, the File Compilation Model and compile-toplevel give details about the processing of top-level forms.
* random-float: new function.Kaz Kylheku2018-07-161-0/+15
| | | | | | | * rand.c (random_float): New function. (rand_init): Register random-float. * txr.1: Documented.
* compile-file: support hash bang.Kaz Kylheku2018-07-111-0/+11
| | | | | | | | | * share/txr/stdlib/compiler.tl (usr:compile-file): Check for a hash bang line in the source file. If so, propagate it to the compiled file. * txr.1: Documented existing support for hash bang in .tlo files, and the translation of hash bang from .tl to .tlo.
* doc: indentation issueKaz Kylheku2018-07-111-2/+5
| | | | | | * txr.1: Fix wrong deindentation after .RS/.RE delimited bulleted lists. A vertical space is needed in one case after a bulleted list.
* Version 198.txr-198Kaz Kylheku2018-07-061-2/+2
| | | | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated. * protsym.c: Regenerated.
* hashing: overhaul part 2.Kaz Kylheku2018-07-051-2/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In this commit we feature-complete the seeded hashing implementation. The *hash-seed* special variable is provided from which newly created hashes take their seed. The make-hash and hash-equal functions get an optional seed argument. A function called gen-hash-seed is provided for obtaining a randomized seed. * hash.c (hash_seed): New macro. (hash_seed_s): New symbol variable. (make_seeded_hash): New function, made from make_hash. (make_hash): Reduced to wrapper around make_seeded_hash. (hash-equal): Take seed argument. (gen_hash_seed): New function. (hash_init): Initialize hash_seed_s and register *hash-seed* special variable. Re-register make-hash with new optional parameter, with regard to make_seeded_hash. Re-register hash-equal with new optional parameter. Register gen-hash-seed. * hash.h (make_seeded_hash): Declared. (hash_equal): Declaration updated. * txr.1: Documented optional seed arguments of make-hash and hash-equal. Documented new *hash-seed* variable and gen-hash-seed function.
* doc: block* isn't elided.Kaz Kylheku2018-06-281-0/+4
| | | | | * txr.1: Make it clear that block* is not subject to progn-conversion.
* doc: deal with [ ] ambiguity in syntax sections.Kaz Kylheku2018-06-071-7/+27
| | | | | | | | * txr.1: In Syntax synopses, use the '[' and ']' notation to denote literal square brackets, since square brackets mean "optional". Updated Conventions sections to document this. Changes under operator drim, if, and and the from-list method.
* Version 197.txr-197Kaz Kylheku2018-05-271-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: wrong eval-only description.Kaz Kylheku2018-05-251-4/+4
| | | | * txr.1: Revise incorrect semantic description of eval-only.
* doc: issues under Awk.Kaz Kylheku2018-05-251-1/+2
| | | | * txr.1: Wrong article "an local" and missing .codn line.
* doc: document the --compiled option.Kaz Kylheku2018-05-241-20/+26
| | | | | * txr.1: Fold --compiled with --lisp into the same description.
* txr: support variable in postive match.Kaz Kylheku2018-05-221-0/+21
| | | | | | | | | | | | | In the @{var mod} syntax in the pattern language, allow mod to be a variable which contains a regex or integer, not just an integer or regex literal. * match.c (h_var): Check for modifier being a variable, and resolve it. * parser.y (modifiers): Allow a SYMTOK phrase. * txr.1: Documented.
* logcount: new function.Kaz Kylheku2018-05-181-0/+19
| | | | | | | | | | | | | | | | | | This is in ANSI CL; potentially useful and hard to implement efficiently in user code. * arith.c (logcount): New function. * eval.c (eval_init): Register logcount intrinsic. * lib.h (logcount): Declared. * mpi/mi.c (s_mp_count_ones): New static function. (mp_count_ones): New function. * mpi/mpi.h (mp_count_ones): Declared. * txr.1: Documented.
* Version 196.txr-196Kaz Kylheku2018-05-181-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* linenoise: switch to wide characters, support Unicode.Kaz Kylheku2015-09-221-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib.c (chk_wrealloc): New function. * lib.h (mem_t): Wrap with ifndef block. (MEM_T_DEFINED): New preprocessor symbol. (chk_wrealloc): Declared. * linenoise/linenoise.c (LINENOISE_MAX_DISP): Adjust to a reasonable value; just twice the number of abstract characters. The 8 factor had been chosen to cover the worst case that every character is mapped to a tab. (struct lino_state): Almost everything char typed turns to wchar_t. The TTY isn't referenced with Unix file descriptors, ifd and ofd, but abstract stream handles tty_ifs and tty_ofs. The ifs member isn't required any more since plain mode is handled via the tty_ifs stream. (mem_t): Declaration removed; now in linenoise.h. (chk_malloc, chk_realloc, chk_strdup_utf8): Declarations removed. (lino_os): New static structure. (nelem): New macro. (wcsnprintf): New static function. (enable_raw_mode, disable_raw_mode): Get Unix FD from stream using lino_os interface. (get_cursor_position, get_columns, handle_resize, record_undo, remove_noop_undo, restore_undo, undo_renumber_hist_idx, compare_completions, complete_line, lino_add_completion, next_hist_match, history_search, show_help, struct abuf, ab_append, ab_free, sync_data_to_buf, refresh_singleline, screen_rows, col_offset_in_str, refresh_multiline, scan_match_rev, scan_match_fwd, scan_fwd, find_nearest_paren, usec_delay, flash, yank_sel, delete_sel, edit_insert, edit_insert_str, edit_move_eol, edit_history_next, edit_delete, edit_backspace, edit_delete_prev_all, edit_delete_to_eol, edit_delete_line, edit_in_editor, edit, linenoise, lino_make, lino_cleanup. lino_free, free_hist, lino_hist_add, lino_hist_save, lino_set_result): Revised using streams, wide chars and lino_os interface. (lino_init): New function. * linenoise/linenoise.h (LINO_PAD_CHAR): New preprocessor symbol. (mem_t): Defined here. (MEM_T_DEFINED): New preprocessor symbol. (struct lino_os, lino_os_t): New structure. (lino_os_init): New macro. (struct lino_completions, lino_compl_cb_t, lino_atom_cb_t, lino_enter_cb_t): Switch to wchar_t. (lino_init): New function. (lino_add_completion, lino_make, linenoise, lino_hist_add, lino_hist_save, lino_hist_load, lino_set_result) * parser.c (find_matching_syms, provide_completions, provide_atom, is_balanced_line, repl): Adapt to wide character linenoise. (lino_fileno, lino_puts, lino_getch, lino_getl, lino_gets, lino_feof, lino_open, lino_open8, lino_fdopen, lino_close): New static functions. (linenoise_txr_binding): New static structure. (parse_init): Call lino_init, passing OS binding. * txr.1: Update text about the listener's limitations.
* Allow Unicode characters in identifiers.Kaz Kylheku2018-05-111-1/+13
| | | | | | | | | | * parser.l (unicode_ident): New static function. (BSCHR, NSCHR): Include UONLY match. (grammar): Use unicode_ident function to validate tokens obtained from BTOK and NTOK. * txr.1: Documented changing definition of bident and lident.
* doc: fix of of.Kaz Kylheku2018-05-071-2/+2
| | | | * txr.1: Two occurrences of "of of" are corrected.
* doc: compiler sections: grammar, awkward wording.Kaz Kylheku2018-05-071-16/+16
| | | | | * txr.1: Overhaul after a proof-reading of the new LISP COMPILATION section.