From: Overnight Date: 2002-09-20T05:58:15+09:00 Subject: Re: self-loading scripts (at Ruby's startup time) > > Thanks. Wouldn't it be useful to have some special-name, autoloading > > script? It would be the necessary starting point in defining a standard > > for what happens at Ruby's startup time. > What would the standard be for how installed ruby libraries insert code > into this file? Why not just use BEGIN {} in the library code? Hi. BEGIN {} in library code would init the library for sure, but how would the library be *automatically* loaded? Pythonistas in this newsgroup surely know about site.py, the special file that Pythons looks for and loads at startup. At current time (and in the ActiveState distro) it is used to standardize the addition of site- specific dirs to Python's search path and the execution of a special "sitecustomize" module. This is something more elaborate that adding - r to RUBYOPT. I was thinking of something similar when I posted my original message. IMHO, "autorun.rb" would be a nice name :-) If autorun.rb existed, some standards could be built upon it. For examples, it could look into a text file ("autolibs" ???) with a list of libs to require at startup, or it could look for the equivalent of "sitecustomize" in Python, and load it. If all this became an accepted standard, a library wishing to make itself autorun at startup could simply add itself to "autolibs". Details of each lib's initialization, as you point out, could then be encapsulated in BEGIN {} blocks within the library. Another rationale for preferring autorun.rb to RUBYOPT, ehm, "hacking" :- ) is that autorun.rb could be included in a distro more easily than code setting up RUBYOPT. And it looks to me that it would be easier to maintain. Well, hope I've been clear enough, sorry if my English is not so good :-) Bye, Andrea