Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!usc!henry.jpl.nasa.gov!elroy.jpl.nasa.gov!gryphon!vector!attctc!bobc From: bobc@attctc.Dallas.TX.US (Bob Calbridge) Newsgroups: comp.lang.c Subject: Silly syntax Keywords: just for grins Message-ID: <9604@attctc.Dallas.TX.US> Date: 7 Oct 89 01:13:49 GMT Distribution: na Organization: The Unix(R) Connection, Dallas, Texas Lines: 34 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! - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=