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


Groups > comp.lang.c > #107956

Re: And they say C is obscure

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: And they say C is obscure
Date 2017-04-09 13:52 -0700
Organization None to speak of
Message-ID <lny3v9wbgh.fsf@kst-u.example.com> (permalink)
References <20170409-035940.754.0@Peabody.ssl.astraweb.com> <ocdtn3$j5q$1@dont-email.me> <loops-vs-calls-20170409192650@ram.dialup.fu-berlin.de>

Show all headers | View raw


ram@zedat.fu-berlin.de (Stefan Ram) writes:
> James Kuyper <jameskuyper@verizon.net> writes:
>>Functionally, this is identical to the loop that Joe Pfeiffer showed
>>you. However, it's possible (but not guaranteed) that the call to
>>memset() may execute significantly faster than that loop - it's quite
>>unlikely to execute significantly slower.
>
>   In C++, AFAIK function calls are preferred to loops. IIRC,
>   one reason is that loops are more error prone (they might have
>   off-by-one errors, or unsigned-loops might never terminate).
>
>   Also, a function name can convey the intent of the author,
>   while a loop has to be analyzed by the reader to understand
>   what it does.
>
>   When one uses a function, OTOH, one has to carefully read
>   the documentation before writing the call.

There's nothing specific to C++ about any of that.

A call to memset() is generally preferred to an equivalent for loop,
because it's simpler and likely to be faster.  Of course you have to
understand what a function does if you're going to call it.  Similarly,
if you write an explicit loop you have to understand how the loop works,
including both the syntax and semantics of a "for" loop and the code
used in the body of the loop.  Functions are just one case of the need
to understand the code you're writing.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

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


Thread

And they say C is obscure Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-08 22:59 -0500
  Re: And they say C is obscure Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-04-08 22:17 -0600
    Re: And they say C is obscure Peabody <waybackNO584SPAM44@yahoo.com> - 2017-04-09 07:42 -0500
      Re: And they say C is obscure Barry Schwarz <schwarzb@dqel.com> - 2017-04-09 07:46 -0700
      Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-04-09 16:47 +0200
      Re: And they say C is obscure James Kuyper <jameskuyper@verizon.net> - 2017-04-09 14:42 -0400
        Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-09 13:25 -0700
          Re: And they say C is obscure James Kuyper <jameskuyper@verizon.net> - 2017-04-09 22:56 -0400
      Re: And they say C is obscure Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-04-09 15:18 -0600
      Re: And they say C is obscure Ken Brody <kenbrody@spamcop.net> - 2017-04-10 12:57 -0400
    Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-10 14:46 +0000
  Re: And they say C is obscure luser droog <luser.droog@gmail.com> - 2017-04-09 07:26 -0700
  Re: And they say C is obscure James Kuyper <jameskuyper@verizon.net> - 2017-04-09 14:18 -0400
    Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-04-09 20:53 +0100
    Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-09 13:52 -0700
      Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-04-14 11:48 +0000
        Re: And they say C is obscure Ken Brody <kenbrody@spamcop.net> - 2017-04-14 13:36 -0400
          Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-04-20 13:24 +0000
            Re: And they say C is obscure supercat@casperkitty.com - 2017-04-20 08:05 -0700
              Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-20 15:32 +0000
                Re: And they say C is obscure supercat@casperkitty.com - 2017-04-20 09:48 -0700
                Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-20 18:00 +0000
                Re: And they say C is obscure supercat@casperkitty.com - 2017-04-20 11:34 -0700
                Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-20 18:41 +0000
  Re: And they say C is obscure Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-04-09 13:18 -0700
    Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-09 14:03 -0700
      Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-09 22:56 +0100
        Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-04-10 09:12 +0200
        Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-10 08:22 -0700
          Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-10 18:28 +0100
            Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-10 17:49 +0000
            Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-10 11:50 -0700
              Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-10 20:33 +0100
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-10 13:06 -0700
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-04-10 21:48 +0100
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-10 22:15 +0100
                Re: And they say C is obscure Michael Barry <barrym95838@yahoo.com> - 2017-04-10 18:46 -0700
                Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-10 21:46 +0000
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-10 23:09 +0100
                Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-11 12:40 +0000
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-11 14:15 +0100
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-26 10:13 -0700
                Re: And they say C is obscure supercat@casperkitty.com - 2017-04-26 10:38 -0700
                Re: And they say C is obscure supercat@casperkitty.com - 2017-04-10 15:23 -0700
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-04-14 11:51 +0000
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-14 13:14 +0100
                Re: And they say C is obscure supercat@casperkitty.com - 2017-04-14 10:42 -0700
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-14 19:04 +0100
                Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-04-14 21:43 +0100
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-26 11:02 -0700
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-04-26 19:05 +0100
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-04-26 12:02 -0700
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-04-26 21:55 +0100
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-27 00:15 +0100
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-27 13:23 -0700
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-04-14 18:12 +0100
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-14 18:37 +0100
                Re: And they say C is obscure GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-04-11 00:03 +0200
              Re: And they say C is obscure Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-04-10 14:10 -0700
                Re: And they say C is obscure mark.bluemel@gmail.com - 2017-04-11 08:41 -0700
                Re: And they say C is obscure supercat@casperkitty.com - 2017-04-11 08:58 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.mclean5@btinternet.com> - 2017-04-11 09:06 -0700
                Re: And they say C is obscure scott@slp53.sl.home (Scott Lurndal) - 2017-04-11 16:46 +0000
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-04-11 19:02 +0100
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-04-14 11:59 +0000
            Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-26 10:59 -0700
              Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-04-27 21:40 +0100
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-02 05:17 -0700
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-03 12:50 -0700
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-05 01:20 -0700
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-05 12:37 -0700
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-06 00:16 -0700
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-06 11:49 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-06 13:16 -0700
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-06 14:10 -0700
                Re: And they say C is obscure Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-05-06 20:23 -0600
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-06 21:51 -0700
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-07 05:04 -0700
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-07 05:09 -0700
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-07 05:18 -0700
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-07 05:54 -0700
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-05-07 13:48 +0100
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-07 06:13 -0700
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-07 15:10 +0200
                Re: And they say C is obscure Manfred <noname@invalid.add> - 2017-05-07 16:47 +0200
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-07 21:08 +0200
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-05-07 21:54 +0100
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-08 00:59 +0200
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-07 16:59 -0700
                Re: And they say C is obscure Robert Wessel <robertwessel2@yahoo.com> - 2017-05-07 22:28 -0500
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-08 10:16 +0200
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-08 02:41 -0700
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-08 07:36 -0700
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-05-09 10:06 +0000
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-09 14:03 +0200
                Re: And they say C is obscure Manfred <noname@invalid.add> - 2017-05-09 19:41 +0200
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-09 21:35 +0200
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-05-09 20:25 +0000
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-10 14:48 +0200
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-10 14:23 +0100
                Re: And they say C is obscure Manfred <noname@invalid.add> - 2017-05-10 21:31 +0200
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-05-10 12:45 -0700
                Re: And they say C is obscure "James R. Kuyper" <jameskuyper@verizon.net> - 2017-05-10 16:49 -0400
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-07 08:56 -0700
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-08 09:54 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-08 17:32 -0700
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-05-08 18:26 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-09 02:28 -0700
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-05-09 10:15 +0000
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-09 05:53 -0700
                Re: And they say C is obscure bartc <bc@freeuk.com> - 2017-05-09 14:15 +0100
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-09 06:55 -0700
                Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-09 14:43 +0100
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-09 23:07 +0100
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-10 15:32 +0200
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-05-10 11:39 +0000
                Re: And they say C is obscure mark.bluemel@gmail.com - 2017-05-09 06:21 -0700
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-11 03:00 -0700
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-05-09 18:20 +0100
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-05-10 10:06 -0700
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-10 11:11 -0700
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-10 12:45 +0100
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-10 05:33 -0700
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-10 13:41 +0100
                Re: And they say C is obscure Jerry Stuckle <jstucklex@attglobal.net> - 2017-05-10 09:32 -0400
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-10 14:51 +0100
                Re: And they say C is obscure Jerry Stuckle <jstucklex@attglobal.net> - 2017-05-10 10:54 -0400
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-10 17:36 +0200
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-10 09:28 -0700
                Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-10 19:12 +0100
                Re: And they say C is obscure me <crisdunbar@gmail.com> - 2017-05-10 11:53 -0700
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-10 22:19 +0200
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-05-11 07:36 +0100
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-11 00:39 -0700
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-11 13:30 +0200
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-11 13:17 +0100
                Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-11 13:37 +0100
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-12 10:39 +0200
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-13 09:34 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-13 09:48 -0700
                Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-13 19:48 +0100
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-13 14:01 -0700
                Re: And they say C is obscure David Kleinecke <dkleinecke@gmail.com> - 2017-05-13 15:23 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-14 03:14 -0700
                [OT] Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-14 12:18 +0100
                Re: [OT] Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-14 13:28 +0100
                Re: [OT] Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-14 15:56 +0200
                Re: [OT] Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-14 16:56 +0100
                Re: And they say C is obscure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-05-14 02:03 +0100
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-14 03:08 -0700
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-14 13:44 +0100
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-14 16:13 +0200
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-14 08:04 -0700
                Re: And they say C is obscure luser droog <luser.droog@gmail.com> - 2017-05-14 08:52 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-14 09:16 -0700
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-14 17:48 +0100
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-14 14:11 -0700
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-14 22:57 +0200
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-05-14 14:10 -0700
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-14 15:51 +0200
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-14 14:04 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-11 07:45 -0700
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-11 16:45 +0100
                Re: And they say C is obscure Gareth Owen <gwowen@gmail.com> - 2017-05-11 19:58 +0100
                Re: And they say C is obscure Ike Naar <ike@iceland.freeshell.org> - 2017-05-11 22:15 +0000
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-11 23:24 +0100
                Re: And they say C is obscure David Brown <david.brown@hesbynett.no> - 2017-05-12 10:50 +0200
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-12 09:57 +0100
                Re: And they say C is obscure Jerry Stuckle <jstucklex@attglobal.net> - 2017-05-10 16:31 -0400
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-10 07:50 -0700
                Re: And they say C is obscure supercat@casperkitty.com - 2017-05-10 09:00 -0700
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-11 03:03 -0700
                Re: And they say C is obscure Keith Thompson <kst-u@mib.org> - 2017-05-11 09:02 -0700
                Re: And they say C is obscure Manfred <noname@invalid.add> - 2017-05-12 18:34 +0200
                Re: And they say C is obscure Richard Heathfield <rjh@cpax.org.uk> - 2017-05-12 18:47 +0100
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-13 09:03 -0700
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-05-09 10:11 +0000
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-09 08:28 -0700
                Re: And they say C is obscure Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2017-05-09 09:40 -0700
                Re: And they say C is obscure raltbos@xs4all.nl (Richard Bos) - 2017-05-09 20:26 +0000
                Re: And they say C is obscure fir <profesor.fir@gmail.com> - 2017-05-10 00:20 -0700
                Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-05-08 09:01 -0700
        Re: And they say C is obscure John Bode <jfbode1029@gmail.com> - 2017-04-11 09:15 -0700
          Re: And they say C is obscure supercat@casperkitty.com - 2017-04-11 09:29 -0700
    Re: And they say C is obscure Manfred <noname@invalid.add> - 2017-04-13 16:00 +0200
      Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-16 19:45 -0700
    Re: And they say C is obscure Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-26 11:09 -0700

csiph-web