changeset 5677:febc025c4e0c

Adopt GNU's ## syntax for the interned symbol with name "". src/ChangeLog addition: 2012-08-06 Aidan Kehoe <kehoea@parhasard.net> * lread.c (read1): * print.c (print_symbol): Adopt GNU's ## syntax for the interned symbol with the zero-length name. man/ChangeLog addition: 2012-08-06 Aidan Kehoe <kehoea@parhasard.net> * lispref/symbols.texi (Symbol Components): Document the new syntax of ## for the symbol with name "" interned in obarray.
author Aidan Kehoe <kehoea@parhasard.net>
date Mon, 06 Aug 2012 13:07:55 +0100
parents dede3f658f8e
children b0d40183ac79
files man/ChangeLog man/lispref/symbols.texi src/ChangeLog src/lread.c src/print.c
diffstat 5 files changed, 32 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/man/ChangeLog	Sat Aug 04 23:26:26 2012 +0900
+++ b/man/ChangeLog	Mon Aug 06 13:07:55 2012 +0100
@@ -1,3 +1,9 @@
+2012-08-06  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* lispref/symbols.texi (Symbol Components):
+	Document the new syntax of ## for the symbol with name "" interned
+	in obarray.
+
 2012-08-02  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.32 "habanero" is released.
--- a/man/lispref/symbols.texi	Sat Aug 04 23:26:26 2012 +0900
+++ b/man/lispref/symbols.texi	Mon Aug 06 13:07:55 2012 +0100
@@ -73,9 +73,15 @@
 Since symbols are represented textually by their names, it is important
 not to have two symbols with the same name.  The Lisp reader ensures
 this: every time it reads a symbol, it looks for an existing symbol with
-the specified name before it creates a new one.  (In XEmacs Lisp,
-this lookup uses a hashing algorithm and an obarray; see @ref{Creating
-Symbols}.)
+the specified name before it creates a new one.  In XEmacs Lisp,
+this lookup uses an hashing algorithm and an obarray; see @ref{Creating
+Symbols}.  In Emacs Lisp, the symbol with the zero-length name has the
+special print syntax @code{##}:
+
+@example
+(intern "")
+        @result{} ##
+@end example
 
   In normal usage, the function cell usually contains a function or
 macro, as that is what the Lisp interpreter expects to see there
--- a/src/ChangeLog	Sat Aug 04 23:26:26 2012 +0900
+++ b/src/ChangeLog	Mon Aug 06 13:07:55 2012 +0100
@@ -1,3 +1,10 @@
+2012-08-06  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* lread.c (read1):
+	* print.c (print_symbol):
+	Adopt GNU's ## syntax for the interned symbol with the zero-length
+	name.
+
 2012-08-02  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* XEmacs 21.5.32 "habanero" is released.
--- a/src/lread.c	Sat Aug 04 23:26:26 2012 +0900
+++ b/src/lread.c	Mon Aug 06 13:07:55 2012 +0100
@@ -2654,6 +2654,8 @@
 
 	      goto retry;
 	    }
+            /* The interned symbol with the empty name. */
+          case '#': return intern ("");
 	  case '$': return Vload_file_name_internal;
             /* bit vectors */
 	  case '*': return read_bit_vector (readcharfun);
--- a/src/print.c	Sat Aug 04 23:26:26 2012 +0900
+++ b/src/print.c	Mon Aug 06 13:07:55 2012 +0100
@@ -2375,8 +2375,6 @@
 print_symbol (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
 {
   /* This function can GC */
-  /* #### Bug!! (intern "") isn't printed in some distinguished way */
-  /* ####  (the reader also loses on it) */
   Lisp_Object name = symbol_name (XSYMBOL (obj));
   Bytecount size = XSTRING_LENGTH (name);
   struct gcpro gcpro1, gcpro2;
@@ -2390,12 +2388,15 @@
 
   GCPRO2 (obj, printcharfun);
 
-  if (print_gensym)
+  if (print_gensym && !IN_OBARRAY (obj))
     {
-      if (!IN_OBARRAY (obj))
-        {
-          write_ascstring (printcharfun, "#:");
-        }
+      write_ascstring (printcharfun, "#:");
+    }
+  else if (0 == size)
+    {
+      /* Compatible with GNU, but not with Common Lisp, where the syntax for
+         this symbol is ||. */
+      write_ascstring (printcharfun, "##");
     }
 
   /* Does it look like an integer or a float? */