help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Invoking a function from a list of functions


From: Yuri Khan
Subject: Re: Invoking a function from a list of functions
Date: Fri, 9 Nov 2018 21:16:52 +0700

On Fri, Nov 9, 2018 at 1:03 PM Tim Johnson <tim@akwebsoft.com> 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 “first-class functions”. 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.

A related term, but from object-oriented programming, is “virtual
method”. This is a narrower concept, that you might want to call
different implementations of a function depending on the type of its
argument.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]