Commit 912826a8 authored by Mark Oteiza's avatar Mark Oteiza

Remove "baroque" use of prefix argument from gensym

'cl-gensym' was simply moved here, but let us take an opportunity to
shed some historical baggage.
* lisp/subr.el (gensym): Remove special treatment of PREFIX as a
number.  Use "g" as prefix to differentiate from cl-gensym defaults.
* doc/lispref/symbols.texi (Creating Symbols): Update accordingly.
* lisp/emacs-lisp/cl-macs.el (cl--gensym-counter, cl-gensym): Restore.
parent 3d96fc15
......@@ -276,8 +276,7 @@ distinct uninterned symbol whose name is also @samp{foo}.
@defun gensym &optional prefix
This function returns a symbol using @code{make-symbol}, whose name is
made by appending @code{gensym-counter} to @var{prefix}. The prefix
defaults to @code{"G"}. If @var{prefix} is a number, it replaces the
value of the counter.
defaults to @code{"g"}.
@end defun
@defun intern name &optional obarray
......
......@@ -161,9 +161,16 @@ whether X is known at compile time, macroexpand it completely in
;;; Symbols.
(defvaralias 'cl--gensym-counter 'gensym-counter)
(defvar cl--gensym-counter 0)
;;;###autoload
(cl--defalias 'cl-gensym 'gensym)
(defun cl-gensym (&optional prefix)
"Generate a new uninterned symbol.
The name is made by appending a number to PREFIX, default \"G\"."
(let ((pfix (if (stringp prefix) prefix "G"))
(num (if (integerp prefix) prefix
(prog1 cl--gensym-counter
(setq cl--gensym-counter (1+ cl--gensym-counter))))))
(make-symbol (format "%s%d" pfix num))))
(defvar cl--gentemp-counter 0)
;;;###autoload
......
......@@ -286,13 +286,10 @@ without silencing all errors."
(defun gensym (&optional prefix)
"Return a new uninterned symbol.
The name is made by appending `gensym-counter' to PREFIX.
PREFIX can be a string, and defaults to \"G\".
If PREFIX is a number, it replaces the value of `gensym-counter'."
(let ((pfix (if (stringp prefix) prefix "G"))
(num (if (integerp prefix) prefix
(prog1 gensym-counter
(setq gensym-counter (1+ gensym-counter))))))
(make-symbol (format "%s%d" pfix num))))
PREFIX is a string, and defaults to \"g\"."
(let ((num (prog1 gensym-counter
(setq gensym-counter (1+ gensym-counter)))))
(make-symbol (format "%s%d" prefix num))))
(defun ignore (&rest _ignore)
"Do nothing and return nil.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment