From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: Invoking a function from a list of functions Date: Fri, 9 Nov 2018 21:16:52 +0700 Message-ID: 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 1541773014 31180 195.159.176.226 (9 Nov 2018 14:16:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2018 14:16:54 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 15:16:50 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 1gL7aa-0007zd-68 for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 15:16:48 +0100 Original-Received: from localhost ([::1]:34385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL7cg-0004Su-MK for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 09:18:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL7b1-0002LM-1X for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 09:17:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gL7ay-0001Ob-2a for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 09:17:14 -0500 Original-Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:45030) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gL7at-0001LB-8j for help-gnu-emacs@gnu.org; Fri, 09 Nov 2018 09:17:08 -0500 Original-Received: by mail-ot1-x331.google.com with SMTP id z33so1691049otz.11 for ; Fri, 09 Nov 2018 06:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=J/DkTfXIoW13QM4hmxFzhO4dorOmB6Jm4ddYNy6Pa3s=; b=m0Lg3DdVJ7BPKji2FPdKKobuq2g3l76XwSYOiiA2JQ7Upc1AnOI20oEVRGsGTCnyFJ ZcqcepBBoqXMzHAqa6ggDppHJcTcjz2sAENFB4mCbH88DxxWE5p10wIZp1bOdPorSNX6 OM4uBuPxVtlhXGjZPq++318CCV7lX+g9744QRuq1maJuEkq/vj90ltH8mVqtLgw0vWPn 8XNDZh/NwjhDG8ZlJ/PbdzQPccjkjw7TeFm0FIMkF+uqsLAfvtag8OP66dF/wRUHvvDm GUccIiftyZFg338xyNHFTlOz36IpiVg47R+meleWvz9If5jcTUAWSuvlEEskbzeKN+qe 24Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-transfer-encoding; bh=J/DkTfXIoW13QM4hmxFzhO4dorOmB6Jm4ddYNy6Pa3s=; b=MiORpwJwLm/9sWQ0FTP7F6LOUbNqQRF1huKUCVAJb5RTtt1Jv5Uep0jnhODrvTiJq5 XWRsEPg0nL5kZlFg57HHoO88b/X1iWsX9tKPiFOxo2QSJzHueefNlKdroDqwI5vw/f4M hqd47hdwVzAc6UzxZQfxxvA/IfYaBiLMhWkU6oO08bcCbuVa2+cjLiQSCvvc8gzpzIic Hwm+iU5IU3ooDtd8uacVfzIm4+ybQ8T5YGyCgQeiHZMQiZUmwFSETdFQ7kmbfIN0xFmQ GCCLQ0bd/WiC8kCC1Xs0sDyACBA8gHN1sUVColEkgQdVkMOX/ncKpVZ2RdC06GCO7uXQ idBw== X-Gm-Message-State: AGRZ1gLxKgIJbo08Y8tTElxD6QaqFD+qUX4Y6jnGNR9z6hFoYaGnSUvk 32rs0MNF0xUOQeG3sHCBW3nmlJ00K48FLNhez3MEPQ== X-Google-Smtp-Source: AJdET5cVM7Dj83HSauma1/wqpTi5DxcXQ9E4JY1AviejRTuabSBVIidSAU9IAmuwmhXSLzqrYGaV7aDIDNgalJmezsc= X-Received: by 2002:a9d:17e9:: with SMTP id j96mr5794902otj.34.1541773024606; Fri, 09 Nov 2018 06:17:04 -0800 (PST) In-Reply-To: <20181109060302.GB2179@mail.akwebsoft.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::331 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:118621 Archived-At: On Fri, Nov 9, 2018 at 1:03 PM Tim Johnson wrote: > > > 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) > 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? The term you are looking for is =E2=80=9Cfirst-class functions=E2=80=9D. Th= is 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. A related term, but from object-oriented programming, is =E2=80=9Cvirtual method=E2=80=9D. This is a narrower concept, that you might want to call different implementations of a function depending on the type of its argument.