all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Mark Oteiza <mvoteiza@udel.edu>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp
Date: Tue, 12 Sep 2017 13:35:55 -0400	[thread overview]
Message-ID: <20170912173555.GA11188@holos.localdomain> (raw)
In-Reply-To: <20170912172125.GA10696@holos.localdomain>

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.



  reply	other threads:[~2017-09-12 17:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170912151313.7686.92637@vcs0.savannah.gnu.org>
     [not found] ` <20170912151315.C449D2087D@vcs0.savannah.gnu.org>
2017-09-12 16:48   ` [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp Stefan Monnier
2017-09-12 17:21     ` Mark Oteiza
2017-09-12 17:35       ` Mark Oteiza [this message]
2017-09-12 18:28       ` Stefan Monnier
2017-09-12 18:51         ` Mark Oteiza
2017-09-13  3:48         ` Alex
2017-09-13 12:40           ` Stefan Monnier
2017-09-13 12:50             ` Mark Oteiza
2017-09-28  7:05               ` Alex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170912173555.GA11188@holos.localdomain \
    --to=mvoteiza@udel.edu \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.