From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleh Newsgroups: gmane.emacs.help Subject: Any disadvantages of using put/get instead of defvar? Date: Thu, 20 Feb 2014 18:04:52 +0100 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1392916256 797 80.91.229.3 (20 Feb 2014 17:10:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Feb 2014 17:10:56 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 20 18:11:02 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 1WGX9I-0006dz-Ly for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Feb 2014 18:11:00 +0100 Original-Received: from localhost ([::1]:39800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGX9I-0004Ys-74 for geh-help-gnu-emacs@m.gmane.org; Thu, 20 Feb 2014 12:11:00 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGX3Q-0003OO-Nu for help-gnu-emacs@gnu.org; Thu, 20 Feb 2014 12:05:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGX3O-0002W6-5f for help-gnu-emacs@gnu.org; Thu, 20 Feb 2014 12:04:56 -0500 Original-Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:45540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGX3N-0002Vq-Up for help-gnu-emacs@gnu.org; Thu, 20 Feb 2014 12:04:54 -0500 Original-Received: by mail-wi0-f173.google.com with SMTP id bs8so1999039wib.0 for ; Thu, 20 Feb 2014 09:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=4JiigSHL74aD5ODiyrsWQBWOz+1NQHJHL7EZDpeb09c=; b=qMK+c8KRxDSp+edgPzX0zYrY7U0HoWKp1H8VKwWxQB8GnmUwyseulnWGa48RtXunFl mOEIWYFKKfQWRRdLAXk8H0juZY6BhJdzABYKIrzeHyq/rbDAtLcwp8IHKNp3HhDfXe2H z2crDSFxUZC8dNPo8pLgmOYdiQ7G7kRJJERLwV58o6mRWhYNNOsjQh56VjWZyktan7a0 NFf0h/jIibcbIS8ElxFTcE32OvV07M/TVt2iWLt8h6dCidDWg/vMxDy3bBrRjh68t5ub f/a0I7q+VFNAt1dNvOhBPF7H49qXUf4u6jCSR8UtnhRRB4CPJLwXrC96A5j/xNFXoeSP pQ1A== X-Received: by 10.195.13.17 with SMTP id eu17mr3180861wjd.24.1392915892871; Thu, 20 Feb 2014 09:04:52 -0800 (PST) Original-Received: by 10.227.147.68 with HTTP; Thu, 20 Feb 2014 09:04:52 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::22d X-Mailman-Approved-At: Thu, 20 Feb 2014 12:10:49 -0500 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:96144 Archived-At: Hi all, I've asked this question on stack overflow and it was suggested that I ask it here as well. The situation is that I have a function that uses one global variable. It's for sure that no other function will want this variable. In an effort to have all code in one place I want to move from: (defvar bar-foo 1) ;; bunch of other code (defun bar () ;; use bar-foo here ) to: (defun bar () (let ((foo (or (get 'bar 'foo) 1))) ;; use foo here )) So the advantage is that I can move and rename the function without worry that the function/variable coupling will break, because now everything is inside one function. I realize that the variable can still be accessed from outside, but that doesn't matter much. One disadvantage listed in the responses was that now the variable can't be buffer-local any more. Any other disadvantages to this method? regards, Oleh