From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Quoted function in `define-key' Date: Sun, 05 Feb 2017 14:50:36 +0100 Message-ID: <8760korbkj.fsf@drachen> References: <874m0a6ywa.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> <874m0ap3ex.fsf@drachen> <87efzedmlk.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> <87zii1dg17.fsf@drachen> <87fujt7xsv.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1486302717 30964 195.159.176.226 (5 Feb 2017 13:51:57 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 5 Feb 2017 13:51:57 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Narendra Joshi Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 05 14:51:54 2017 Return-path: Envelope-to: geh-help-gnu-emacs@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 1caNEP-0007pk-NP for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2017 14:51:53 +0100 Original-Received: from localhost ([::1]:43342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caNEV-0001aF-9B for geh-help-gnu-emacs@m.gmane.org; Sun, 05 Feb 2017 08:51:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35265) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caNDJ-0001AD-C3 for help-gnu-emacs@gnu.org; Sun, 05 Feb 2017 08:50:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1caNDE-00076d-Gz for help-gnu-emacs@gnu.org; Sun, 05 Feb 2017 08:50:45 -0500 Original-Received: from mout.web.de ([212.227.17.12]:50856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1caNDD-00076H-U8 for help-gnu-emacs@gnu.org; Sun, 05 Feb 2017 08:50:40 -0500 Original-Received: from drachen.dragon ([188.98.111.232]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Ma2Pz-1csIvy0SzP-00Lmjb; Sun, 05 Feb 2017 14:50:37 +0100 In-Reply-To: <87fujt7xsv.fsf@vicarie.i-did-not-set--mail-host-address--so-tickle-me> (Narendra Joshi's message of "Sun, 05 Feb 2017 15:40:40 +0530") X-Provags-ID: V03:K0:Kx5kWLqjI7iaT9gIVqM2D3D00Tm6Z0FUKFGdMomKI80vP3XuI+Q 91w4ixW53jWsxr9yJdRRKhkt5pSGl4AMTaLAdaqAso9w0vo0VRKskYoM6qRh9wCZQIajYhf 1H2l+L6QQc6cUjLdjvYs2qwGMQQdhOM/sPcqwzuWxfAsMjXSCVvpAF1K3MQpwl64BxVwbBz kZBtfQFMIIEVNEPEc/eSw== X-UI-Out-Filterresults: notjunk:1;V01:K0:T7JtmSqT8QU=:zH335FFicNdeOn91xZLVVz Hgjl13MpXlMu4sZbvzKG0bI2yk2HCsqNTQvPYXPWdRnDf1o0YWL4UY+gZ05Z1FdzZxbW1bGh0 4B/BQ+zlOWIlWQC4NWGa1f8Dao2zwid+DBH0tZcleV6/qm7Z7cyGgScLIPVXLTG1iIN/9QLmw FMCglL1vM7bxVgOfuqSg96fIaB+2ZcwMF6nE3lS/nCk5fBJ3EBrRWiASHGOwtdhxsvxOGiho8 6ku6iSVPhCfw1tW+NKZyZdJNbc+lzBiUmJQ/gLwg0l1fIdFAQ1MPm/HwWdiwjTzsSb9JB055V NF7MdboGyXLCWLn6ozzMEA233WgwOvMOAVxl3+RuBPBTJMtuR8ZL3Ye5WeKEf5/zMcN6nrcPp IFoubf1CFPD/5PoxkM+9rC3CcADXVZgra24ZqSZK2m3pHSXy+lC/LJIAf8MMVLxbsMpi2bV9i 9KMRfuokNAijaDeWx3t8K5AMhFb2tpj1Z2XbyVRn3VwY9Pt12pC0QSvtotimfPXMY6mwCI2I0 TJf0P2hkYzx1zRUEWaIu1ApRQz0xXGvu4+SPDQgNpGiJJHuFoe3RJL6+SLNANm694GhCkc2ap J3rxERb4M73iD35CTLMkhrSybMWtHqIiniiQqOHLMomx1zpYSWk1Nrfuph/pYtuxd67Wi9kLx P4IObUO2zS+qs6eArnBrnFVe0vcd8qF4VpjptHexuCeNL8xpUluOqZpF5fLJB5j+ykVG7C8RF +KFrJapC1/k4irxSR2MG2/BkqG68GNUYLXbbPZClzPdTMSNyDK9b3eZs1wEvrnx7GD2b+zYN X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.17.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:112252 Archived-At: Narendra Joshi writes: > So, the symbol `my-function' can have the function definition in its > value slot? There's a separate slot for function bindings. You can refer to it directly with passing the symbol to `symbol-function'. So any symbol can have two separate "bindings" - a binding as a variable, and one as a function (unlike scheme, for example). That's why Elisp is a Lisp-2. Actually, there is one more cell for symbol property lists ("plists"). See (info "(elisp) Symbol Components") for more details. > What does the byte compiler do with this information? I am just > curious about this. When you sharp quote a lambda expression, the compiler knows that this lambda list is supposed to be called as a function, and will byte compile it. The evaluator might turn it into a closure when lexical binding is used. In elisp, the `lambda' macro comes with implicit function quoting (see its definition), so you can just omit it. But OTOH, it's an error to `quote' lambdas like '(lambda () body...) because it will prevent byte compilation or closure creation and make Stefan angry. Obviously for `function' quoted symbols there is not much to do, but the byte compiler can determine whether that function is defined/ will be defined at run time, so it can warn you about typos as an extra service. For example, you get a compiler warning when compiling (define-key my-map [key] #'make-frame-cmomand) but not for (define-key my-map [key] 'make-frame-cmomand) > If this is recommended, I would also start quoting my functions as > #'my-function. Yes, it's a good idea. Michael.