From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.help Subject: Re: sending function arguments to recursive function calls Date: Mon, 20 May 2013 23:31:40 +0400 Message-ID: <87obc5v46b.fsf@yandex.ru> References: <0F54256BD7B94384AC4DDA919D502C20@us.oracle.com> <4D1DF48A7223443FA454C07B20B80E21@us.oracle.com> <87mwrt7py6.fsf@yandex.ru> <2AC6E6871319483CABA0387DEF8B39CC@us.oracle.com> <878v3aofcy.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1369078333 6697 80.91.229.3 (20 May 2013 19:32:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 May 2013 19:32:13 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: "Pascal J. Bourguignon" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon May 20 21:32:12 2013 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 1UeVoY-0006ys-WC for geh-help-gnu-emacs@m.gmane.org; Mon, 20 May 2013 21:32:11 +0200 Original-Received: from localhost ([::1]:44195 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeVoY-0000Y3-KI for geh-help-gnu-emacs@m.gmane.org; Mon, 20 May 2013 15:32:10 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:57086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeVoF-0000Xb-KG for help-gnu-emacs@gnu.org; Mon, 20 May 2013 15:31:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UeVo7-0005BM-CV for help-gnu-emacs@gnu.org; Mon, 20 May 2013 15:31:51 -0400 Original-Received: from mail-la0-x236.google.com ([2a00:1450:4010:c03::236]:43575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UeVo7-0005B6-4U for help-gnu-emacs@gnu.org; Mon, 20 May 2013 15:31:43 -0400 Original-Received: by mail-la0-f54.google.com with SMTP id eg20so4091916lab.41 for ; Mon, 20 May 2013 12:31:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type:x-antivirus :x-antivirus-status; bh=uAPyFjQKvSijI/DJHrKWmz3s84SuVm3cYqdkbe+Ofqk=; b=mBJRm/3Kdej0Uf8qxRCIbKosmy+KWr+x3gGIVu1dLZvmJijHn3MmTh4J3p8DnPKuBu 0KMiFQD6Knydq9ejfW8dt8pkEgbmKFHX+olfH/BfF+sL+CoxJVZBHD82Q/60rh5oYbvc E7pRFqA6mzXwqahlEwB0QXCT4InVPIbX/U4DrMAxfnwaeoNoBvCUW8HD+NMb2bPVJRHX 3Nwe+V9zODDg87X38u0bxiALA8hHjqKdB5InNr/V3xP+Eml5vE+ZBqjmu0NesXfaE9NA 21A4OIozgtvA7KQU+lJomSFi1UyTnAn34T6bAFeyVct4V1M3nod7V0W0WbHEw4PuqTQ/ BqJQ== X-Received: by 10.112.88.194 with SMTP id bi2mr27942199lbb.111.1369078301953; Mon, 20 May 2013 12:31:41 -0700 (PDT) Original-Received: from SOL ([178.252.98.87]) by mx.google.com with ESMTPSA id f9sm5001496lbf.4.2013.05.20.12.31.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 May 2013 12:31:40 -0700 (PDT) In-Reply-To: <878v3aofcy.fsf@kuiper.lan.informatimago.com> (Pascal J. Bourguignon's message of "Sun, 19 May 2013 22:59:41 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) X-Antivirus: avast! (VPS 130520-0, 20.05.2013), Outbound message X-Antivirus-Status: Clean X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c03::236 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:90925 Archived-At: "Pascal J. Bourguignon" writes: > Then you meant to write: > > bar > > not: > > baz > Right. Sorry. >> It's ugly because this kind of code is hard to reason about and, >> consequently, hard to modify. Suppose I want to rewrite `foo' (and >> suppose it's longer than this one line). > > Yes. That's why you should adopt the CL convention of naming all the > special variables (those with dynamic binding) with stars: > I agree it's a good convention in CL (and Clojure), but Elisp has its own convention: name the variable starting with the package prefix. Until we have real modularity, it should be good enough. >> Can I rename `bar' to something else? > > Yes. You should name it *bar*, and declare it special locally. Right, > for now (declare (special *bar*)) has no effect in emacs lisp since it's > the default, but it states your intent! Yes, I think, currently only byte-compiler looks at it, and warns the user when it sees undeclared variables. >> No idea: to be absolutely sure, >> I have to search the definitions of all functions that `foo' calls, >> and if I find a `bar' reference in any of them, I'll now have to >> search for any other functions that call them, etc. IOW, this makes >> for terrible composability. > > Definitely. That's why the default is lexical binding, and you have to > declare specially variables with dynamic binding, either with declare > special, or globally with defvar or defparameter. > > >> The behavior is ugly because it allows the code to be written this way. >> >> A worse example is when `bar' is one of the arguments to `foo' (ugh). > > Global or local special declarations are still possible, even for > parameters. ...in CL, right? Your earmuff example didn't work for me in Emacs with lexical-binding t, `(declare (special *bar*))' doesn't replace the need for `defvar'ing it. I'm not sure how I feel about special local variables and parameters. The problem with tracking down callers/callees graph applies to both of these types, as far as I can tell, so each local variable of this kind might as well be declared global. During the few years I've been using Emacs, I think I've only used the ability to change the value of a parameter in a caller function once, deep inside the Helm codebase. Sure enough, in a few months, the caller function code has changed, and my function broke.