From: Hal Fulton Date: 2003-12-11T05:15:37+09:00 Subject: Re: Ideas for replacing $0==__FILE__ Eric Hodel wrote: > Hal Fulton (hal9000@hypermetrics.com) wrote: > > >>I'm thinking (again) about the idiom "if $0 == __FILE__" and >>trying to come up with viable alternatives. >> >>It seems to me that we don't really need an "executable" thing >>like exit/break/return/quit in this context. >> >>It could just be a "marker" as someone suggested. >> >>My two favorites so far are __TEST__ and __MAIN__. >> >>As far as I can see, there should be no conflict or interaction >>with the __END__ marker. > > > We also discussed on IRC having a "-t" flag to the ruby interpreter that > would run a TEST block (like BEGIN or END or at_exit), but __TEST__ > seems even better than that. Are we talking about the same thing? In my scheme, if foo.rb had a __TEST___ section, it would be run simply by ruby foo.rb (and not run if foo.rb was require'd). How does that relate to the -t idea (which I don' quite get)? Hal