Aidan Kehoe avatar Aidan Kehoe committed febc025

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.

Comments (0)

Files changed (5)

+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.

man/lispref/symbols.texi

 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
+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.
 
 	      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);
 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;
 
   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? */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.