From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tim Johnson Newsgroups: gmane.emacs.help Subject: Re: Invoking a function from a list of functions Date: Fri, 9 Nov 2018 07:22:01 -0900 Organization: AkWebsoft Message-ID: <20181109162201.GD2179@mail.akwebsoft.com> References: <20181108230125.GA2179@mail.akwebsoft.com> <87o9azoxdh.fsf@ericabrahamsen.net> <20181109060302.GB2179@mail.akwebsoft.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 1541780440 29730 195.159.176.226 (9 Nov 2018 16:20:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2018 16:20:40 +0000 (UTC) User-Agent: Mutt/1.10.0 (2018-05-17) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 17:20:36 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 1gL9WM-0007ce-AF for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 17:20:34 +0100 Original-Received: from localhost ([::1]:34938 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL9YS-0004Z2-Oy for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 11:22:44 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL9Xs-0004Yj-SK for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 11:22:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gL9Xn-0001A8-Ie for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 11:22:08 -0500 Original-Received: from tjohnson.mtaonline.net ([64.4.232.191]:49244) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL9Xn-00018e-8d for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 11:22:03 -0500 Original-Received: by linus (Postfix, from userid 1000) id 83046240436; Fri, 9 Nov 2018 07:22:01 -0900 (AKST) Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.4.232.191 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:118625 Archived-At: * Yuri Khan [181109 05:28]: > On Fri, Nov 9, 2018 at 1:03 PM Tim Johnson wrote: >=20 > > > > Given a list of functions: > > > > (setq funcs '(scroll-up-line scroll-down-line)) > > > > > > > > And assuming that these functions have a similar argument list, > > > > I can invoke a function as: > > > > > > > > (funcall (nth 1 funcs)) > > > > ;; or optionally > > > > (funcall (nth 1 funcs) 2) >=20 > > What I am interested in is further discussion whether it be from > > replies to this topic or more general topics in this area. I'm > > restating that I've had a difficult time finding results from > > google. > > > > -------------------------------------------------------- > > That is probably because I don't know the right keywords > > or domain-specific terms to use > > -------------------------------------------------------- > > > > This isn't just difficult for emacs/elisp, I've found it difficult > > for python functions invoked from lists or dictionaries. (altho > > I've employed such methods for years in python) > > > > If I wished to further research this topic using a search engine > > what are the keywords that I might feed to google? >=20 > The term you are looking for is =E2=80=9Cfirst-class functions=E2=80=9D= . This refers > to passing functions as arguments to other functions, returning > functions out of functions, storing functions in variables and data > structures, and otherwise treating functions the same way as other > values. That is exactly correct, yet I find nothing on this topic using=20 =E2=80=9Cfirst-class functions=E2=80=9D as a keyword/phrase. This obscurity is shared by python. The 'list-or-dictionary-of- function= s=20 approach that I've used for years in python is just as hard to search for. I believe I also used that tactic in C back when I did GUI programming, but it has been so very long and I'm so very retired ... :) > A related term, but from object-oriented programming, is =E2=80=9Cvirtu= al > method=E2=80=9D. This is a narrower concept, that you might want to cal= l > different implementations of a function depending on the type of its > argument. >=20 thanks --=20 Tim Johnson http://www.tj49.com