Invoking pointers to functions (C sytle)

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Wed Dec 5 10:07:33 AEST 1990


In article <989 at mwtech.UUCP> martin at mwtech.UUCP (Martin Weitzel) writes:
  [ usage should be absolutely symmetric to declaration ]

Agreed.

  [ in ANSI C, if foo points to a function, you can call foo(x) ]
  [ this breaks symmetry ]

Agreed.

  [ therefore only (*foo)(x) should be allowed ]

Well, that's one solution, but this one is more natural: The name of a
function has type ``pointer to function.'' So after int foo() { ... },
the object ``foo'' refers to has type pointer-to-function-returning-int.
And all functions are called through function pointers. Symmetry is
preserved.

Why is this more natural? Because it's how the machine does it. In the
absence of any other criteria, the realistic solution is the natural
one.

---Dan



More information about the Comp.lang.c mailing list