Silly syntax

Bob Calbridge bobc at attctc.Dallas.TX.US
Sat Oct 7 11:13:49 AEST 1989


This is something that passed through my mind and I thought I's ask the
wizards here if it is possible.  Though I've been working with C on and off
for a couple of years I don't get the chance to get deeply involved with
extremely complex programs.  Therefore, when, from time to time, I see a
clever use of the flexibility of the language I get intrigued with the
possibilities.  So I ended up with the question as to where a function
may be used in expressions.  Mainly, can it be used anyplace that a variable
or a constant may?  One example that came to mind, though I have no immediate
concept of how it might be used, is can a function be used as the argument to
a case statement?  For example:

	switch (expression) {
		case f1():	do_this();
				break;
		case f2():	do_that();
				and_that();
		case f3():	while (youre_at(it)) {
					take_out(the_garbage);
					put_out(the_cat);
				};
				break;
		case adnauseum:	honk();
	}

where f1...fn() may be functions that evaluate circumstances and return an
integer or get input from the user and return an integer.  I have vague 
ideas as to why something may be implemented this way, if it is even possible.
I just don't have an immediate need, just an immense curiosity.  Is the
language that flexible or is it possible to violate this concept?
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=             I know it's petty..........                                     =
-                  But I have to justify my salary!                           -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



More information about the Comp.lang.c mailing list