summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-12-29 16:52:52 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-12-29 16:52:52 -0800
commit9361473290d317186768bd9d709ae76adf9d85b8 (patch)
treeb4f649994b1491d2749b164cb8b05c308355b7fc /txr.1
parent079cf1d067ec21e590f0ec025cbc282f8290e2fa (diff)
downloadtxr-9361473290d317186768bd9d709ae76adf9d85b8.tar.gz
txr-9361473290d317186768bd9d709ae76adf9d85b8.tar.bz2
txr-9361473290d317186768bd9d709ae76adf9d85b8.zip
read, iread: source location recording now conditional.
Recording of source location info incurs a time and space penalty. We don't want to impose this on programs which are just reading large amounts of Lisp data that isn't code. * eval.c (eval_init): Register lisp-parse and read functions to the newly introduced nread function rather than lisp_parse. lisp_parse continues to record source location info unconditionally. * parser.c (rec_source_loc_s): New symbol variable. (parser_common_init): Set the new member of the parser structure, rec_source_loc, according to the current value of the special var *rec-source-loc*. (lisp_parse_impl): New second argument, rlcp_p. If true, it overrides the rec_source_loc member of the parser structure to true. (lisp_parse): Pass true argument to rlcp_p parameter of lisp_parse_impl, so parsing via lisp_parse always records source loc info. (nread): New function. (iread): Pass true argument to rlcp_p parameter of lisp_parse_impl, so *rec-source-loc* controls whether source location info is recorded. (parse_init): Initilize rec_source_loc_s symbol variable, and register the *rec-source-loc* special var. * parser.h (struct parser): New member, rec_source_loc. (rec_source_loc_s, nread): Declared. * parser.y (rlcp_parser): New static function. Like rlcp but does nothing if parser->rec_source_loc is false. (rlc): New macro. (grammar): Replace rlcp uses with rlc, which expands to a call to rlcp_parser. (rlrec): Do nothing if source loc recording is not enabled in the parser. (make_expr, uref_helper): Replace rlcp with rlc. This is possible because these functions have a parser local variable that the macro expansion can refer to. (parse_once): Override rec_source_loc in the parser to 1, so that source loc info is always recorded when parsing is invoked through this function. * txr.1: Documented *rec-source-loc* and added text under read and iread.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.135
1 files changed, 35 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index f948f155..a90b5a8a 100644
--- a/txr.1
+++ b/txr.1
@@ -43888,6 +43888,16 @@ possibility that the expression will be further extended by means of the dot or
dotdot operators. An explicit end-of-input signal must be given from the
terminal to terminate the expression.
+The special variable
+.code *rec-source-loc*
+controls whether these functions record source location info similarly to
+.codn load .
+Note: if these functions are used to scan data which is evaluated as Lisp code,
+it may be useful to set
+.code *rec-source-loc*
+true in order to obtain better diagnostics. However, source location recording
+incurs a performance and storage penalty.
+
.coNP Function @ record-adapter
.synb
.mets (record-adapter < regex >> [ stream <> [ include-match ]])
@@ -54616,6 +54626,31 @@ has location info, the expander propagates that info to that form's
expansion. In some situations, it is useful for a macro or other code
transformer to perform this action explicitly.
+.coNP Special variable *rec-source-loc*
+.desc
+The Boolean special variable
+.code *rec-source-loc*
+controls whether the
+.code read
+and
+.code iread
+functions record source location info. The variable is
+.code nil
+by default, so that these functions do not record source location info.
+If it is true, then these functions record source location info.
+
+Regardless of the value of this variable, source location info is
+recorded for Lisp forms which are read from files or streams under the
+.code load
+function or specified on the \*(TX command line. Source location
+info is also always recorded when reading the \*(TX pattern language syntax.
+
+Note: recording and propagating location info incurs a memory and performance
+penalty. The individual cons cells and certain other literal objects in the
+structure which emerges from the parser are associated with source location
+info via a global weak hash table.
+
+
.coNP Function @ macro-ancestor
.synb
.mets (macro-ancestor << form )