Davidsen's device

Oliver Laumann net at tub.UUCP
Fri Aug 4 22:59:08 AEST 1989


In article <1430 at crdgw1.crd.ge.com> davidsen at crdos1.UUCP (bill davidsen) writes:
>   I recently discovered the following technique. While I can't swear
> that it's new and unique to me, I can claim independent discovery. I
> make no claims that it is suited to any problem you have, will have, or
> would admit to having.
> 
> 	(*(asect < 1.0 ? hacs2 : hacs1)(asect);

This is quite a common idiom, I have used it lots of times (without the
syntax error in your example, of course).

You can even omit the * since it's superfluous.

Or is it?  Our K&R (the old edition) doesn't seem to say anything about
this, but "gnucc -pedantic -ansi" doesn't complain about the following
program (a good heuristic for checking whether it's valid C):

int g() { return 5; }

int foo() {
    int (*f)() = g;
    return f();
}

--
Oliver Laumann              net at TUB.BITNET              net at tub.UUCP



More information about the Comp.lang.c mailing list