arrays...

David Goodenough dg at lakart.UUCP
Tue May 10 00:06:28 AEST 1988


>From article <282 at teletron.UUCP>, by andrew at teletron.UUCP (Andrew Scott):
> I was struck by Chris' comment, however.  How would unnamed functions be
> implemented?  How would they be used?  The { .. } syntax for aggregate declar-
> ations seems natural enough to use for unnamed aggregates, but how would it
> be done for functions?

Something like this:

	int (*foo)();	/* foo is a pointer to a func returning int */

	foo = (a, b) int a, b;
		{
		return (a < b ? a : b);
		};

would make foo point to an unnamed function that returns the minimum of it's
two arguments.

The most obvious use for such a "feature" (?) would be in the invocation
of routine like qsort, which takes a function as an argument:

	qsort(array, nelem, sizeof(char *),
		(a, b) char **a, **b
		 {
		    return (strcmp(*a, *b));
		 }				);

Kind of ikky, but you get the idea.

P.S. don't suggest this to the ANSI crowd: we don't need another re-run of the
noalias 
-- 
	dg at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!adelie!cfisun!lakart!dg	+-+-+ |
						  	  +---+



More information about the Comp.lang.c mailing list