What should be added to C

aglew at ccvaxa.UUCP aglew at ccvaxa.UUCP
Thu May 29 05:01:00 AEST 1986


~> Things that should/could be added to C, or C++, or...

typeof
	typeof would be a compile time operator that would 
	have a (possibly compressed and tokenized) form of
	the type used in declaring its argument (a variable)
	inserted in its place.

	If the C preprocessor ever gets sophisticated enough
	to be a true macro processor, typeof should return a
	string that macro operations can parse and disassemble
	as they will. In particular, typeof(typedef-name) 
	should return the type used in declaring the type-name,
	and so on.

lambda
	Wherever you may have a variable, it should be possible
	to substitute a literal constant of the appropriate type.
	C fails this test for arrays, which hasn't been so serious
	for the applications I've seen (I don't like having to declare
	COMPLEX constants as initialized variables, but C has so many
	other weaknesses for constants that I don't care - I'll wait
	for C++ constructors) -- more importantly, C also fails this
	test for function-pointers.

	When I pass a function pointer to, say, an integration routine,
	I would like to not have to go to the bottom of the file 
	somewhere and write the function. f it's a short, anonymous
	function that I'm not going to use anywhere else, I want to 
	declare it in place.

	I've used preprocessors that let you do this:
		integrate(from,to,
			float lambda(x) float x; {return x*x;}
		)
	and move the declaration to the end and create a special name
	for it.



More information about the Comp.lang.c mailing list