summaryrefslogtreecommitdiffstats
path: root/txr.1
Commit message (Collapse)AuthorAgeFilesLines
...
* 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.
* Version 195.txr-195Kaz Kylheku2018-05-041-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim: Regenerated.
* doc: break up long syntax.Kaz Kylheku2018-05-021-9/+14
| | | | | | | | * txr.1: The syntax synopses for the following functions and macros are too long and are awkwardly wrapped by man under 80 columns: make-time, make-time-utc, make-env, call-update-expander, call-clobber-expander and txr-if. Breaking up and shortening some identifiers.
* doc: fix recurring syntax formatting error.Kaz Kylheku2018-05-021-12/+12
| | | | | | * txr.1: I spotted a problem in the syntax synopsis of remq, remql and remqual. The same mistake was made in a few other places. remq* also had an error, though different.
* Version 194.txr-194Kaz Kylheku2018-04-301-1/+1
| | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise.
* Version 193.txr-193Kaz Kylheku2018-04-261-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* compiler: implement eliding of blocks.Kaz Kylheku2018-04-241-0/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is time-wasting to have a block in every function. In this patch we have the compiler eliminate blocks if it is obvious that they will not be the targets of any exits or continuation captures through any direct function calls. If a block contains only calls to library functions, and doesn't call certain functions, then it is removed. It is possible for this removal to be strictly wrong and different from interpreted code. This is true if the code enclosed in a block invokes a function indirectly or via a quoted symbol, and that function tries to return from the block or capture a continuation using that block as a prompt. Such a call doesn't prevent the block from being removed. For instance, this won't work in compiled code any more: (defun tricky (fun) (call fun)) (tricky (lambda () (return-from tricky 42))) The call function is considered safe; the (call fun) form doesn't prevent the block inside the tricky function from being removed. * share/txr/stdlib/compiler.tl (blockinfo): New struct. (env): New slot, bb. (env lookup-block, env extend-block): New methods. (%block-using-funs%): New global variable. (compiler comp-block): Implement the elision of the block based on what free functions are referenced in the body, and whether the block is referenced lexically. Also, bind the block in the environment using the bb member in the env structure. (comp-return-from): Lookup the block lexically and mark it as used. (system-symbol-p): New function. * txr.1: Document the rules for elision of blocks.
* New macro: load-time.Kaz Kylheku2018-04-231-0/+297
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is similar to the ANSI CL load-time-value. * eval.c (load_time_s, load_time_lit_s): New symbol variables. (op_load_time_lit, me_load_time): New static functions. (eval_init): Intern load-time symbol and sys:load-time-lit. Register the sys:load-time-lit special operator and load-time macro. * share/txr/stdlib/asm.tl (assembler parse-args): We must now allow the d registers to be the targets of a mov instruction, because load-time depends on being able to mutate the data vector, in order to turn the result of a calculation into a de facto literal. * share/txr/stdlib/compiler.tl (compiler): New member, lt-frags. (compile-in-toplevel): New macro. (compiler alloc-dreg): New method. (compiler compile): Handle sys:load-time-lit special form via comp-load-time-lit method. (compiler comp-load-time-lit): New method. (usr:compile-toplevel): Prepend the load-time assembly code fragments to the compiled assembly code. * vm.c (vm_set, vm_sm_set): Do not reject an attempt to modify the static data, since load-time now generates mov instructions targetting the d registers. * txr.1: Document load-time.
* Version 192.txr-192Kaz Kylheku2018-04-191-2/+2
| | | | | | | | | | * RELNOTES: Updated. * configure, txr.1: Bumped version and date. * share/txr/stdlib/ver.tl: Likewise. * txr.vim, tl.vim, protsym.c: Regenerated.
* doc: continuations: compiled vs interpreted.Kaz Kylheku2018-04-191-1/+38
| | | | | | | | * txr.1: Turn the comparison with lexical closures into a named subsection instead of Notes. Add subsection about mutated lexical variables and continuations: how the behavior can differ between interpreted and compiled code. Point user to the hlet and hlet* macros.