From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Proper use of function form Date: Mon, 27 Apr 2020 02:05:29 +0200 Message-ID: <87h7x5kd2u.fsf@web.de> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="111934"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:Qnla6Wi2223UuSIh9PkXp9pGD0I= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 27 02:08:24 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jSrJw-000T1y-Me for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Apr 2020 02:08:24 +0200 Original-Received: from localhost ([::1]:49084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSrJv-0002IU-G1 for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 26 Apr 2020 20:08:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49456) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jSrHK-0002IG-77 for help-gnu-emacs@gnu.org; Sun, 26 Apr 2020 20:05:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jSrHJ-0008LI-Nx for help-gnu-emacs@gnu.org; Sun, 26 Apr 2020 20:05:42 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:54408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jSrHH-0008Kn-SM for help-gnu-emacs@gnu.org; Sun, 26 Apr 2020 20:05:41 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jSrHD-000QSA-KG for help-gnu-emacs@gnu.org; Mon, 27 Apr 2020 02:05:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=159.69.161.202; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/04/26 19:08:06 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:122947 Archived-At: Tim Johnson writes: > Would it be better to change (nth (+ ndx 1) mylist) to > (function (nth > (+ ndx 1) mylist)) ? No: "Like `quote', but preferred for objects which are functions. In byte compilation, `function' causes its argument to be handled by the byte compiler. `quote' cannot do that." "(nth > (+ ndx 1) mylist)" is not a function - it is an expression that will evaluate to a function. Since `function' acts like `quote', using this special form would prevent that evaluation, so it won't work. The underlying problem is that your expression is evaluated at run-time. Useful for the compiler would only be a function name known at compile time. If you know the function name at compile time, you don't want to eval it at run time, so you want to `quote' anyway. So what can you do? Since we don't have a multiple-define-key function, you can just stay with your loop as is - there is nothing wrong with that, but you'll not get compiler warnings like "unknown function". You can also use a macro that would expand to a sequence of `define-key' calls at compile time. Or construct the whole keymap at compile time, using list functions (or `backquote'). But that's rather uncommon. Most people just write the key definition calls out or just don't care - even in the Emacs sources. Michael.