ANSI C idea: structure literals

Karl Heuer karl at haddock.ISC.COM
Wed Mar 9 02:36:14 AEST 1988


In article <139 at puivax.UUCP> ian at puivax.UUCP (Ian Wilson) writes:
>Another place where anonymous objects would be handy is for functions
>embedded in data structures. For example: ...
>	(*(&remote( (*)(char * x), {printf("%s\n", x);} )));

Actually, to be consistent with my proposal the first operand of `remote`
should be the type of the object, not of the pointer.  Thus
	remote( void (char *x), {printf("%s\n", x);} )
would be equivalent to mentioning the (non-existent) name of the remote
function, hence this gives you a function pointer without using "&".  (As has
been pointed out to me by e-mail, I made this mistake in my char[] example.)
Using it as above would allow you to stuff it into a function table; or you
could invoke it via
	remote( void (char *x), {printf("%s\n", x);} )("hello, world");

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list