]> git.saurik.com Git - bison.git/commitdiff
doc: motivate named references.
authorJoel E. Denny <joeldenny@joeldenny.org>
Mon, 30 May 2011 00:06:22 +0000 (20:06 -0400)
committerJoel E. Denny <joeldenny@joeldenny.org>
Mon, 30 May 2011 00:52:42 +0000 (20:52 -0400)
Suggested by Hans Aberg at
<http://lists.gnu.org/archive/html/bug-bison/2011-05/msg00008.html>.
* doc/bison.texinfo (Named References): Explain briefly how
they're better than the traditional positional references.

ChangeLog
doc/bison.texinfo

index 2bcb75d85c48ab2b482a86a35b58c8683f1c491c..ea82a41d5ac04ff1b62f3c63c4b76676dc29e62c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-29  Joel E. Denny  <joeldenny@joeldenny.org>
+
+       doc: motivate named references.
+       Suggested by Hans Aberg at
+       <http://lists.gnu.org/archive/html/bug-bison/2011-05/msg00008.html>.
+       * doc/bison.texinfo (Named References): Explain briefly how
+       they're better than the traditional positional references.
+
 2011-05-29  Joel E. Denny  <joeldenny@joeldenny.org>
 
        doc: discuss named references after locations.
index 8fdac074ae066d11ce0fe3833d178dcd631b3e90..42ea8e287d48be67305003cf0c798b5ce209b354 100644 (file)
@@ -4018,10 +4018,16 @@ statement when it is followed by a semicolon.
 @section Using Named References
 @cindex named references
 
-While every semantic value can be accessed with positional references
-@code{$@var{n}} and @code{$$}, it's often much more convenient to refer to
-them by name.  First of all, original symbol names may be used as named
-references.  For example:
+As described in the preceding sections, the traditional way to refer to any
+semantic value or location is a @dfn{positional reference}, which takes the
+form @code{$@var{n}}, @code{$$}, @code{@@@var{n}}, and @code{@@$}.  However,
+such a reference is not very descriptive.  Moreover, if you later decide to
+insert or remove symbols in the right-hand side of a grammar rule, the need
+to renumber such references can be tedious and error-prone.
+
+To avoid these issues, you can also refer to a semantic value or location
+using a @dfn{named reference}.  First of all, original symbol names may be
+used as named references.  For example:
 
 @example
 @group
@@ -4031,8 +4037,7 @@ invocation: op '(' args ')'
 @end example
 
 @noindent
-The positional @code{$$}, @code{@@$}, @code{$n}, and @code{@@n} can be
-mixed with @code{$name} and @code{@@name} arbitrarily.  For example:
+Positional and named references can be mixed arbitrarily.  For example:
 
 @example
 @group