From: Michael Neumann Date: 2004-07-30T23:48:40+09:00 Subject: Re: Forward references? Lloyd Zusman wrote: > Is there a way to define forward references to functions? Due to my own > personal eccentricities, I like to have the main body of a program > appear at the top of its source file, and the functions it uses at the > end. > > By "define forward reference", I mean something analogous to the > following C construct: > > static char* foo(); /* forward reference */ > static char* bar(); /* forward reference */ > > main () { > printf("%s\n", foo()); > printf("%s\n", bar()); > exit(0); > } > > char* foo() { > return ("foo"); > } > > char* bar() { > return ("bar"); > } > > If I could make use of forward references in ruby, the above program > could look something like this: > > # somehow, define a forward reference to function foo() > > # somehow, define a forward reference to function bar() > > # program starts here > x = foo() > y = bar() > puts x > puts y > exit(0) Wrap this code into a END block: END { x = foo y = bar ... } Regards, Michael