[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp
From: |
Mark Oteiza |
Subject: |
Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp |
Date: |
Tue, 12 Sep 2017 13:35:55 -0400 |
User-agent: |
Mutt/1.9.0 (2017-09-02) |
On 12/09/17 at 01:21pm, Mark Oteiza wrote:
> On 12/09/17 at 12:48pm, Stefan Monnier wrote:
> > > +(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'."
> >
> > I understand that Common-Lisp has that "PREFIX is a number"
> > functionality, but I could never find a use-case for it, so I wonder why
> > we carry over that baggage to Elisp?
>
> It was just simpler to not duplicate the code for such a small
> historical tidbit. I have no problem with the idea of dropping it.
Is this what you mean? (I lowered the prefix for good measure)
diff --git a/doc/lispref/symbols.texi b/doc/lispref/symbols.texi
index 2d9ec6fda3..cda5f1c40f 100644
--- a/doc/lispref/symbols.texi
+++ b/doc/lispref/symbols.texi
@@ -276,8 +276,7 @@ Creating Symbols
@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
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index eee5953882..3405c92e8d 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -161,9 +161,16 @@ cl--expr-depends-p
;;; 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
diff --git a/lisp/subr.el b/lisp/subr.el
index ebb8b53b50..52d4e190e7 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -286,13 +286,10 @@ gensym-counter
(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.
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Stefan Monnier, 2017/09/12
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Mark Oteiza, 2017/09/12
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp,
Mark Oteiza <=
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Stefan Monnier, 2017/09/12
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Mark Oteiza, 2017/09/12
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Alex, 2017/09/12
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Stefan Monnier, 2017/09/13
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Mark Oteiza, 2017/09/13
- Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp, Alex, 2017/09/28