Article View: comp.std.c
Article #4343Re: "Overloaded" function in C
From: Norman Diamond
Date: Thu, 09 Nov 1995 07:17
Date: Thu, 09 Nov 1995 07:17
39 lines
2108 bytes
2108 bytes
In article <47m4dl$eje@gaia.ns.utk.edu>, elemings@unix1.utm.edu (Eric Lemings) writes:
>#include <stdio.h>
>#define f(x, y) ((x) / (y))
>int (f)(int x, int y, int z) { return (x * y + z); }
>int main(void) {
> int a = f(9, 2);
> int b = (f)(9, 2, 4);
> printf("f(9, 2) = %d", a);
> printf("(f)(9, 2, 4) = %d", b);
> return (0);
> }
>Hunting season is now open.
Just because the standard provides a cliff in front of you, you are not
necessarily required to jump off it.
The standard also provides gets() and also permits you to use the / operator
without first checking whether the divisor is non-zero.
>I tried this on a Standard C/Unix system compiler and it worked.
This doesn't tell you whether your program was strictly conforming, or
whether it happened to take advantage of an implementation extension
that could reasonably be provided for other purposes, or whether it
happened to take advantage of an unreasonable implementation extension
which generated a required diagnostic that you didn't notice but which
still proceeded to do what the extender intended.
>Not sure how useful it is though.
Some people considered it useful if the function involved is part of
the standard library (and might be declared by a standard header both
as a macro and as an external identifier). In the case of your own
function, it might help protect a trade secret :-)
--
<< If this were the company's opinion, I would not be allowed to post it. >>
"I paid money for this car, I pay taxes for vehicle registration and a driver's
license, so I can drive in any lane I want, and no innocent victim gets to call
the cops just 'cause the lane's not goin' the same direction as me" - J Spammer
Technical Details
Message-ID:
<47s9u6$chq@usenet.pa.dec.com>Path:
arc1-ca.pugleaf.net!jrd.dec.com!diamondReferences:
<47m4dl$eje@gaia.ns.utk.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!jrd.dec.com!diamond From: diamond@jrd.dec.com (Norman Diamond) Newsgroups: comp.std.c Subject: Re: "Overloaded" function in C Date: 9 Nov 1995 07:17:26 GMT Organization: DEC Japan Research and Development Center Distribution: world Message-ID: <47s9u6$chq@usenet.pa.dec.com> References: <47m4dl$eje@gaia.ns.utk.edu> NNTP-Posting-Host: jit533.jrd.dec.com