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


Groups > comp.lang.c > #148909

Re: K&R function definition with typedef parameter names

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.lang.c
Subject Re: K&R function definition with typedef parameter names
Date 2020-01-10 16:14 +0100
Organization A noiseless patient Spider
Message-ID <qva4d3$cfr$1@dont-email.me> (permalink)
References (3 earlier) <qv7gfc$oir$1@news.albasani.net> <3eba021e-5533-4582-b2db-040965839eeb@googlegroups.com> <a9bd7ff2-4f04-4b8c-9d7f-c194b32d76a5@googlegroups.com> <qv9fo5$j60$1@dont-email.me> <87muavihre.fsf@bsb.me.uk>

Show all headers | View raw


On 10/01/2020 14:05, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
> <cut>
>> And I am completely at a loss to see how K&R style function definitions
>> ever offer any kind of advantage over modern C function definitions with
>> full prototypes.  Maybe I have missed something that you are thinking
>> about, and you can elaborate.
> 
> One possible example is with code the uses a table of heterogeneous
> functions.  In C-with-prototypes the code is undefined unless the
> function pointer is cast to right type at the point of call.  In K&R C,
> the call is well-defined provided the (promoted) types match.

That would be a reason (not a good one, IMHO, but that is beside the
point - and has been discussed before) to use K&R style non-prototype
function /declarations/, but not a reason to use K&R style function
definitions.

> 
> This is a rather narrow window of advantage because in a translator the
> type information may well be known and the correct cast could be
> generated.  None the less, it might be simpler not to.  And in
> interpreted code it's impossible to cast to the right type (since C has
> no run-time type values) so this looks like a big win.  However,
> interpreted code often uses it's own "value type" so all the functions
> could simply be declared variadic or they could take a pointer to an
> array or values.
> 

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


Thread

K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-04 19:31 -0800
  Re: K&R function definition with typedef parameter names Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-05 04:00 +0000
    Re: K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-09 06:26 -0800
  Re: K&R function definition with typedef parameter names James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-04 23:15 -0500
    Re: K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-09 06:27 -0800
  Re: K&R function definition with typedef parameter names Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-05 06:47 +0100
    Re: K&R function definition with typedef parameter names Steve Keller <keller@no.invalid> - 2020-01-09 06:25 -0800
      Re: K&R function definition with typedef parameter names Bonita Montero <Bonita.Montero@gmail.com> - 2020-01-09 16:22 +0100
        Re: K&R function definition with typedef parameter names James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-09 08:20 -0800
          Re: K&R function definition with typedef parameter names Thiago Adams <thiago.adams@gmail.com> - 2020-01-09 10:49 -0800
            Re: K&R function definition with typedef parameter names David Brown <david.brown@hesbynett.no> - 2020-01-10 10:22 +0100
              Re: K&R function definition with typedef parameter names Ben Bacarisse <ben.usenet@bsb.me.uk> - 2020-01-10 13:05 +0000
                Re: K&R function definition with typedef parameter names David Brown <david.brown@hesbynett.no> - 2020-01-10 16:14 +0100
                Re: K&R function definition with typedef parameter names Richard Damon <Richard@Damon-Family.org> - 2020-01-10 11:15 -0500
                Re: K&R function definition with typedef parameter names James Kuyper <jameskuyper@alumni.caltech.edu> - 2020-01-10 20:51 -0500
              Re: K&R function definition with typedef parameter names Thiago Adams <thiago.adams@gmail.com> - 2020-01-10 06:24 -0800
                Re: K&R function definition with typedef parameter names David Brown <david.brown@hesbynett.no> - 2020-01-10 16:26 +0100
          Re: K&R function definition with typedef parameter names Nick Bowler <nbowler@draconx.ca> - 2020-01-13 22:12 +0000
  Re: K&R function definition with typedef parameter names Autist <autist69@gmail.com> - 2020-01-10 16:42 +0100
  Re: K&R function definition with typedef parameter names Tim Rentsch <tr.17687@z991.linuxsc.com> - 2020-01-11 09:56 -0800

csiph-web