Anonymous Functions.
Peter da Silva
peter at ficc.UUCP
Thu May 19 01:00:49 AEST 1988
Reposted because news wasn't getting off-site. My fault.
In article <282 at teletron.UUCP>, andrew at teletron.UUCP (Andrew Scott) writes:
> The { .. } syntax for aggregate declar-
> ations seems natural enough to use for unnamed aggregates, but how would it
> be done for functions?
(lambda nil (...
Just kidding. How about:
a = (int ()(int i)) {
for(i=0; i < 10; i++)
if(foo(i)==MAGIC) break;
return i;
}(b);
And again:
int (*f)(int) = &(int ()(int i)) { ... };
a = (*f)(b);
Yow! Auto functions! Back to BCPL. But I think it's neat.
In article <2706 at geac.UUCP>, daveb at geac.UUCP (David Collier-Brown) writes:
> | In article <11325 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> qsort(base, nel, width, compar)
> char *base;
> int (*compar)();
> EXAMPLE
> qsort(base, nel, width, { return zcomp($1,$2) });
qsort(base, nel, width, &(int ()(int a, b)){ return zcomp(a, b); } );
> Note the problem with parameters...
I'm actually beginning to like this syntax. Is this a fatal character flaw?
--
-- Peter da Silva, Ferranti International Controls Corporation.
-- Phone: 713-274-5180. Remote UUCP: uunet!nuchat!sugar!peter.
More information about the Comp.lang.c
mailing list