From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Garreau\, Alexandre" Newsgroups: gmane.emacs.help Subject: Getting functions usage examples [Was: Re: Knowing where a function has been used (e.g. for optimizing) [Was: Re: Optimising Elisp code]] Date: Sun, 07 Oct 2018 15:46:27 +0200 Message-ID: References: <638fb7dc-6fc5-4645-8793-97a00038a3a8@googlegroups.com> <86tvlyx71z.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1538920707 7287 195.159.176.226 (7 Oct 2018 13:58:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 7 Oct 2018 13:58:27 +0000 (UTC) User-Agent: Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu) 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 15: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 1g99Ze-0001mR-Fl for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 15:58:22 +0200 Original-Received: from localhost ([::1]:42498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g99bk-00042G-Pm for geh-help-gnu-emacs@m.gmane.org; Sun, 07 Oct 2018 10:00:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g99az-0003xG-LT for help-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:59:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g99OR-00043z-0i for help-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:46:47 -0400 Original-Received: from portable.galex-713.eu ([2a00:5884:8305::1]:55624) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g99OQ-0003vq-Ll for help-gnu-emacs@gnu.org; Sun, 07 Oct 2018 09:46:46 -0400 Original-Received: from localhost ([::1] helo=portable.galex-713.eu) by portable.galex-713.eu with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1g99OM-0002EC-MB for help-gnu-emacs@gnu.org; Sun, 07 Oct 2018 15:46:42 +0200 X-GPG-FINGERPRINT: E109 9988 4197 D7CB B0BC 5C23 8DEB 24BA 867D 3F7F X-Accept-Language: fr, en, it, eo In-Reply-To: <86tvlyx71z.fsf@zoho.com> (Emanuel Berg's message of "Sun, 07 Oct 2018 14:41:44 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:5884:8305::1 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:118181 Archived-At: On 2018-10-07 at 14:41, Emanuel Berg wrote: > Garreau, Alexandre wrote: > >> (examples are the other >> great way of learning: inherenthly more >> imperfect than a definition but quicker and >> easier) > > There should always first be the definition, Agree. Yet sometimes people are bad at abstraction, so when the abstraction grow complex, in order to *more easily* understand the example, after one trye, one can begin by getting a guess of what it does, through an example (with a context, of course, because side-effects (and imperative programming generally) and complex data stractures), and then come back at the definition. > then one simple example, then a more > complicated example, then the example that > confirms the rule. as not everybody needs examples, and ideally we should just keep using only definitions, nobody (we hope) will waste a lot of precious time putting 2-3 call examples in the docstrings (especially if it=E2=80=99s something complex so for each you need to describe a valid context). Since the function is only dynamically typed, unless you begin inference-typing or basing on symbols names, you will have a hard time at automatically generating the simplest meaningful examples. So having a grasp of =E2=80=9Chow is this function used in reality=E2=80=9D= may be quite useful=E2=80=A6 and *then*, afterwards, someone could try something more complex, intuitive and experimental, such as of these (potentially thousands, or more) examples, automatically sorting out the most simple, the most idiomatics, the better ones. Then of course I get this may go from quite straightforward for one special library function used one or three times around, to grow especially complex as for =E2=80=9Clist of functions where `+' / `point' / `progn' is used=E2=80=9D. And, regard to optimization, again, for these examples (the most used functions), if one got automatically inlined, then it would require too much recompiling, then the compiler might figure out it shouldn=E2=80=99t i= nline it (unless the programmer accept to do so (maybe it could suggests her about it (wrt its magnitude of usage through the rest of emacs)?)).