"Lloyd Zusman" <ljz / asfast.com> schrieb im Newsbeitrag
news:m3n01g5p5c.fsf / asfast.com...
> "Robert Klemme" <bob.news / gmx.net> writes:
>
> > "Lloyd Zusman" <ljz / asfast.com> schrieb im Newsbeitrag
> > news:m3wu0l6kpd.fsf / asfast.com...
> >>
> >> [ ... ]
> >>
> >>   def main
> >>     # my main routine
> >>     #
> >>     # ... etc. ...
> >>     #
> >>     return (exitcode)  ### or this:  exit(exitcode)
> >>   end
> >>
> >>   def function1
> >>     # ... etc. ...
> >>   end
> >>
> >>   def function2
> >>     # ... etc. ...
> >>   end
> >>
> >>   # other functions ...
> >>
> >>   # final line ...
> >>   exit(main)
> >
> > Sorry, but I get the feeling that you are trying to make Ruby similar to
C
> > too much.  IMHO the result is worse than straight ruby code.  Let Ruby
be
> > Ruby and C be C. :-)
>
> I just want to have my program's main body at the top of the program
> file, and the subsidiary functions at the end.  The only thing C-like
> about this is the fact that I chose the word "main" for the routine that
> houses the main body of code.
>
> This construct is not necessary.  I could just as easily name the main
> routine as "foobar", and it would look less C-like without losing the
> fact that the main body of the code comes first in the program file.

Here's another idea: put your code into two files and require (or load) the
helper code.

Or put your helper code after __END__ and use eval to compile it:

eval DATA.read

p foo()
p bar()

__END__

def foo
  "foo"
end

def bar
  "bar"
end


> Never fear ... the code that I write tends to look ruby-ish and not
> C-like. :)

Dare you!  :-)

Kind regards

    robert