"Robert Klemme" <bob.news / gmx.net> wrote:
> "Kent Dahl" <kentda+news / stud.ntnu.no> schrieb im Newsbeitrag
> news:c6tmj9$58n$1 / orkan.itea.ntnu.no...
> > Robert Klemme wrote:
> > > Where would you expect it to reside?  Maybe the best solution is
> > >
> > > $0      : path as used for invocation
> > > __FILE__: abs path to current file
> > >
> > > Then I agree. :-)  Any objections?  Does this break existing code?
> >
> > Wouldn't this break the idiom of using
> >
> > if __FILE__ == $0 then
> >   #...
> > end
> >
> > to make a file both require-able and executable?
> > I know I use it frequently.
> 
> Yeah, I think it is used quite frequently.  Darn.  The only ad hoc
> sulution to this that occurs to me is to override __FILE__#== and $0#== to
> repair this.  Now this starts getting ugly...  Simon?

Agree, the line 'if __FILE__ == $0' is indeed ugly

There is 4 things wrong with it:

A)  $0 is a global variable, with a very short name, 
    not selfexplaining.

B)  people sometimes write to $0, when they want to tell 
    ps or top, what the process are currently doing.
    this is fragile, I have been hit by it one time.

C)  __FILE__ and $0 is relative paths.
    this is fragile, I have been hit by it more than one time.

D)  making the comparison, seems kludgy.

I remember it took me forever to figure these things out.


I think its time to rethink __FILE__ and get rid of $0.

--
Simon Strandgaard