From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Mark Oteiza Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master 35c893d 2/2: Move gensym to core Elisp Date: Tue, 12 Sep 2017 13:35:55 -0400 Message-ID: <20170912173555.GA11188@holos.localdomain> References: <20170912151313.7686.92637@vcs0.savannah.gnu.org> <20170912151315.C449D2087D@vcs0.savannah.gnu.org> <20170912172125.GA10696@holos.localdomain> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1505237834 24889 195.159.176.226 (12 Sep 2017 17:37:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 12 Sep 2017 17:37:14 +0000 (UTC) User-Agent: Mutt/1.9.0 (2017-09-02) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 12 19:37:09 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drp78-0005GK-9H for ged-emacs-devel@m.gmane.org; Tue, 12 Sep 2017 19:36:46 +0200 Original-Received: from localhost ([::1]:37816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drp7F-0001ub-Ee for ged-emacs-devel@m.gmane.org; Tue, 12 Sep 2017 13:36:53 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drp6Q-0001tO-9W for emacs-devel@gnu.org; Tue, 12 Sep 2017 13:36:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drp6L-0002hV-CR for emacs-devel@gnu.org; Tue, 12 Sep 2017 13:36:02 -0400 Original-Received: from mail-qk0-x235.google.com ([2607:f8b0:400d:c09::235]:37652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1drp6L-0002hM-8C for emacs-devel@gnu.org; Tue, 12 Sep 2017 13:35:57 -0400 Original-Received: by mail-qk0-x235.google.com with SMTP id b82so26645164qkc.4 for ; Tue, 12 Sep 2017 10:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=udel-edu.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bASL+Um7B/5uecNJ5TY1EhDp+V+V2zSba6s4YReWltQ=; b=n510jZLTXhfiu2q1PdelyxoFcMMYxAFNStuwy0Hm+PzaOAPnoCzpxK0VmKbYYUHJdD B1Qvg2c2738sc95xZmRL0JGkR1GdrFT3yryTUa3c7gwYnF8K1RNpMP243QWHPA7Zy+rF nMJ0qCleVGg2RQiR6USDxOTa/QGI/BdTIvp9pWlXHo/AmJZSMpbls5u0VGq8O0DPQjuo Ky3LjlXXQ38TURcZmyX7ON7ksqvRoAExxh+vDJ+7Aydt6SA0s4ox4VQR+qS6IEESG3Wf gNeUOBEkmLGxiycCYvT82lpvzs3lXnBXp5cqXVgsTBouN3dlL7vC9pd7LJu/qlemH/B8 VCrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bASL+Um7B/5uecNJ5TY1EhDp+V+V2zSba6s4YReWltQ=; b=oukFJFEIxkTonhZmhp0qysLNFEssbukA6dEAqJCbycTkj7Y6eXnr2QUZMb4DBs6Bzt Ndctb4h9o+mZ+UXVU4CPgomYVeLAy9sQRA692s/Hq5JpeEkF2PJodYe5FN0IWksvwria 7UWG9oFiuVDEpCD0bC341LE19BXgxcTLq+eQkpTeHLnFl3tim8gGCQN41xuUecRSsUWB srXKeUyQ5xdwEHGtAVNrwT0tBwA+CENyo+fLs1afQZsjigIbFOuxDn/c07Cpxjili4xG P01UdDWQvZT4LXzV3vdFtNZb/OZ1SKGr+HihHybjd7n/bxH9h0yu15BEJR6ppgAzG9df mNkw== X-Gm-Message-State: AHPjjUiSM2k4J67MQDbLjF81/fRXDL8J8soMbs7kjTPXPhavYdzFfs64 hCJ+W/TSjH9r2FScVEGflh+r X-Google-Smtp-Source: AOwi7QB/NcU4RpcKI3vZzSKAZkByCVQzVbqnmKCwTaaahzJ9bAz13shVCwA0WbcJVv+0lvNoA6IU3Q== X-Received: by 10.55.22.218 with SMTP id 87mr20982618qkw.248.1505237756452; Tue, 12 Sep 2017 10:35:56 -0700 (PDT) Original-Received: from holos.localdomain (pool-173-67-36-61.bltmmd.fios.verizon.net. [173.67.36.61]) by smtp.gmail.com with ESMTPSA id n88sm6391325qki.49.2017.09.12.10.35.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Sep 2017 10:35:55 -0700 (PDT) Original-Received: by holos.localdomain (Postfix, from userid 1000) id 5CB8568221; Tue, 12 Sep 2017 13:35:55 -0400 (EDT) Content-Disposition: inline In-Reply-To: <20170912172125.GA10696@holos.localdomain> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::235 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218143 Archived-At: 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.