lambda defs in C

Dataram Miruke dmiruke at isis.UUCP
Fri Feb 7 14:45:37 AEST 1986


> I often find myself creating highly localized register variables in an
> attempt to synthesize common sub expression optimization:
> 
> 	{
> 		register  char _q = *((x.y)->z);
> 
> 		if (_q == 'a' || _q == 'b' || _q == 'c') { ...
> 
> I also want to return values from arbitrary expressions like a for loop.
> Lisp has something called a lambda definition which is something like
> a local temporary function definition. Sort of like:
> 
> 	if ( lambda int f(register char _q = *((x.y)->z)) {
> 			return(_q == 'a' || _q == 'b' || _q == 'c');
> 		}	/* end of lambda def */ ) { ...
> 
> or
> 
> 	x = lambda int f() {
> 		for (...) {
> 			...
> 			return(some expression);
> 			...
> 		}	/* for */
> 	}	/* lambda */
> 
> So, academically, if we were to add a simlar feature to a new dialect of C,
> or to construct a pre-preprocessor for ansii C (a la C++), what problems
> do you see?
> 
> K. Richard Magill
	Don't the inline functions in C++ provide a similar feature?

							- Datta Miruke



More information about the Comp.lang.c mailing list