From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Optimising Elisp code Date: Sat, 06 Oct 2018 22:57:22 -0400 Organization: A noiseless patient Spider Message-ID: References: <638fb7dc-6fc5-4645-8793-97a00038a3a8@googlegroups.com> <86r2h44fqg.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1538881107 21755 195.159.176.226 (7 Oct 2018 02:58:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2018 02:58:27 +0000 (UTC) User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Oct 07 04:58:23 2018 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 1g8zGw-0005Xl-Oq for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 04:58:22 +0200 Original-Received: from localhost ([::1]:40956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8zJ2-0004ah-Uc for geh-help-gnu-emacs@m.gmane.org; Sat, 06 Oct 2018 23:00:32 -0400 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!barmar.motzarella.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 74 Original-Injection-Info: barmar.motzarella.org; posting-host="fee3c4fa1a9412cf2314e064fb7146ce"; logging-data="29819"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191/RbUyD9vBgl7UJ+Nd2Ps" Cancel-Lock: sha1:NdItZcA+ahgdVtresKUJzesRkPk= Original-Xref: usenet.stanford.edu gnu.emacs.help:224045 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:118171 Archived-At: In article <86r2h44fqg.fsf@zoho.com>, Emanuel Berg wrote: > Barry Margolin wrote: > > > You can also define an inline function using > > defsubst. From the Elisp manual: > > > > An inline function works just like an > > ordinary function except for one thing: when > > you compile a call to the function, the > > function's definition is open-coded into > > the caller. > > This rings a bell from the C++ days when/where > you could define a member function as "inline". > That's all I remember, but maybe it was > something similar to this? I think it amounted > to, instead of making a call, that function was > coded into the object itself, and for this > reason it was suited for really short, > simple functions. > > Yes, what does it mean that "the function's > definition is open-coded into the caller"? > > If the caller is a function, does this mean > instead of calling the other function, the > other function's code is put into the first > function so there isn't a second call but > everything is executed in the first function? Yes, that's what "open-coded" means. > > > Making a function inline makes explicit calls > > run faster. > > Well, yeah, obviously since there is no second > invocation with just the original function put > onto the stack! > > What are "explicit calls"? Regular calls, > right? But then what are implicit calls? > Anonymous functions? Or is an inline function > being executed an implicit call to > that function? Calling the function with funcall or apply, e.g. (funcall some-fun x y z) The variable some-fun might contain an ordinary function or an inline function, but the compiler doesn't know what it will be so it can't expand it. > > > But it also has disadvantages. For one thing, > > it reduces flexibility; if you change the > > definition of the function, calls already > > inlined still use the old definition until > > you recompile them. > > Another good point, but that's obvious as well. > > (Hey, for a person who doesn't understand this, > I sure sound confident enough :)) Yep, you're picking it up OK. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me ***