Re: 3 Questions

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 01/31/01


On Wed, 31 Jan 2001, George Greer wrote:

> If you want variables in the middle of functions, then your functions
> are too fat.

Maybe.  But I can think of some places where it's desirable:

  switch (cond) {
  case val1:
    int my_var; /* illegal */
    . . .
    break;
  default:
    . . .
  }

or, as you said, long functions.  But C sort of mandates the use of long
functions.  If the original function (which is too fat) has a lot of state
and cannot be split-up reasonably, then breaking up the function into
helpers requires rather inconvenient state-passing mechanisms.  A better
solution, of course, would be provided via a namespace or environment,
providing us with "closures" (where the environment of the function is
included with the function).  Allowing the state to be declared in an
environment that is shared by the functions, rather than inside the
functions.  Another way to do this, I guess, is with nested functions.


-dak

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/03/01 PST