From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nicolas Richard Newsgroups: gmane.emacs.help Subject: Re: Any disadvantages of using put/get instead of defvar? Date: Fri, 21 Feb 2014 11:29:23 +0100 Message-ID: <8738jcg3ng.fsf@yahoo.fr> References: <87ob218lsu.fsf@thinkpad-t61.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392978576 2941 80.91.229.3 (21 Feb 2014 10:29:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 21 Feb 2014 10:29:36 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Feb 21 11:29:43 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WGnMU-0007T9-K7 for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Feb 2014 11:29:43 +0100 Original-Received: from localhost ([::1]:43511 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGnMT-0002c0-S0 for geh-help-gnu-emacs@m.gmane.org; Fri, 21 Feb 2014 05:29:41 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGnMB-0002bn-Hr for help-gnu-emacs@gnu.org; Fri, 21 Feb 2014 05:29:30 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGnM4-0007ZV-7l for help-gnu-emacs@gnu.org; Fri, 21 Feb 2014 05:29:23 -0500 Original-Received: from mxin.ulb.ac.be ([164.15.128.112]:19700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGnM4-0007ZM-2W for help-gnu-emacs@gnu.org; Fri, 21 Feb 2014 05:29:16 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ap4EAOspB1OkD4Xx/2dsb2JhbABZxE+BJ3SCJQEBBAF5EAgDISUPAQRJiAMBDAirfphBAYgzF4djhwEHhDgEmDSGMYt2gy47 Original-Received: from mathsrv4.ulb.ac.be (HELO geodiff-mac3) ([164.15.133.241]) by smtp.ulb.ac.be with ESMTP; 21 Feb 2014 11:29:14 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 20 Feb 2014 20:40:08 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 164.15.128.112 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:96151 Archived-At: >> You could also define the variable inside the function, i.e., that's a >> buffer-local counter: >> (defun counter () >> (defvar counter-var 1) >> (setq-local counter-var (1+ counter-var))) > > I'd recommend against it. Its semantics is pretty much the same as > > (defun counter () > (defvar counter-var 1) > (setq-local counter-var (1+ counter-var))) Did you mean this instead ? (defvar counter-var 1) (defun counter () (setq-local counter-var (1+ counter-var))) -- Nico.