Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #153142

Re: a design question here

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: a design question here
Date 2020-07-08 00:27 +0100
Organization A noiseless patient Spider
Message-ID <87blkqucrg.fsf@bsb.me.uk> (permalink)
References <6ed5d30c-b551-4a6c-8faa-47826085f841o@googlegroups.com> <50478be8-9720-483e-8bf4-d22d05cf9c83o@googlegroups.com>

Show all headers | View raw


Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Tuesday, 7 July 2020 13:52:13 UTC+1, G G  wrote:
>> why would you want to have a function return a function?
>>
> As your title suggests, it's a design methodology.
>
> In C, you can't return a function, though you can return a function 
> pointer. So you can't build functions at runtime using the standard
> language,

Your "so" is misleading.  The fact that you can't return a function,
only a pointer to one, is not the reason you can't construct functions
at run-time in C.  The reason is simply that the language does not
permit it.

<cut>
> However some other languages encourage building functions at runtime.

I think it's worth noting that, at least among modern programming
languages, it's very common.  Of course that depends on exactly what we
mean.  Even Algol 68 could "return a function", but it had no concept of
a closure, so what these returned functions could do was rather limited.

> It's a different way of thinking about programming.

I think you may be conflating returning function values with functional
(or declarative) programming.  Obviously there is a connection, but a
function returning function often fits perfectly naturally into the
conventional way of thinking about programming.  You don't have to go
full-on FP (see the note about Algol 68 above).

-- 
Ben.

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

a design question here G G <gdotone@gmail.com> - 2020-07-07 05:52 -0700
  Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-07 06:32 -0700
    Re: a design question here zoidberg@planet.express (John A. Zoidberg) - 2020-07-07 14:19 +0000
      Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-07 07:26 -0700
        Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-07 07:51 -0700
    Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-07 07:22 -0700
      Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-07 09:20 -0700
    Re: a design question here Bonita Montero <Bonita.Montero@gmail.com> - 2020-07-07 18:43 +0200
  Re: a design question here Anton Shepelev <anton.txt@g{oogle}mail.com> - 2020-07-07 16:44 +0300
  Re: a design question here Eli the Bearded <*@eli.users.panix.com> - 2020-07-07 17:38 +0000
  Re: a design question here Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-07-07 11:03 -0700
    Re: a design question here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-07-08 00:27 +0100
      Re: a design question here Eli the Bearded <*@eli.users.panix.com> - 2020-07-07 23:45 +0000
        Re: a design question here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-07-08 01:29 +0100
          Re: a design question here Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-07-07 17:32 -0700
            Re: a design question here The Real Non Homosexual <cdalten@gmail.com> - 2020-07-07 18:50 -0700
  Re: a design question here "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-07-07 12:10 -0700
    Re: a design question here "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2020-07-07 12:11 -0700
  Re: a design question here G G <gdotone@gmail.com> - 2020-07-09 14:45 -0700
    Re: a design question here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-07-10 00:31 +0100
    Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-10 00:38 -0700
      Re: a design question here The Real Non Homosexual <cdalten@gmail.com> - 2020-07-11 07:30 -0700
  Re: a design question here G G <gdotone@gmail.com> - 2020-07-09 20:03 -0700
  Re: a design question here "jfbod...@gmail.com" <jfbode1029@gmail.com> - 2020-07-20 15:45 -0700
    Re: a design question here James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-07-20 19:15 -0400
      Re: a design question here Bart <bc@freeuk.com> - 2020-07-21 00:34 +0100
        Re: a design question here richard@cogsci.ed.ac.uk (Richard Tobin) - 2020-07-21 10:18 +0000
          Re: a design question here Richard Damon <Richard@Damon-Family.org> - 2020-07-21 07:41 -0400
          Re: a design question here James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-07-21 08:51 -0400
            Re: a design question here Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2020-07-21 06:13 -0700
            Re: a design question here richard@cogsci.ed.ac.uk (Richard Tobin) - 2020-07-21 14:21 +0000
              Re: a design question here David Brown <david.brown@hesbynett.no> - 2020-07-21 16:59 +0200
              Re: a design question here Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-07-21 20:10 +0100
              Re: a design question here fir <profesor.fir@gmail.com> - 2020-07-23 09:36 -0700
            Re: a design question here jacobnavia <jacob@jacob.remcomp.fr> - 2020-07-21 18:58 +0200
              Re: a design question here James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-07-22 14:18 -0700
          Re: a design question here scott@slp53.sl.home (Scott Lurndal) - 2020-07-21 15:22 +0000
          Re: a design question here Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2020-07-21 11:51 -0700

csiph-web