discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] Re: import


From: Stan Shebs
Subject: Re: [OT] Re: import
Date: Fri, 21 Dec 2001 16:19:35 -0800

Pascal Bourguignon wrote:
> 
> The #import  CPP directive is defined  as including a  given file once
> ever in a  compilation run, and that's enough to  be an improvement to
> #include.

You're casually assuming that "a given file" is a well-defined
concept.  In the presence of symlinks, relative paths, and multiple
-I directives on the command line, that's just not true.  In fact,
correct implementation of #import requires looking at inodes to
verify identity, which is not portable because inodes are a Unix
thing.  (I have a patch in Apple's GCC that does this for some
pathological cases that occur in OS X code, needs to be cleaned
up for FSF submission still.)

I think what happened with #import is that it was originally intended
to be a genuine interface-loading construct, but somewhere along the
way it got turned into an intelligent #include.  #import <classname>
wouldn't have the file identity issue of #import <filename>, because
there is only one global space of classes, and behind the scenes you
could have a database of classes for the compiler to look in.  Alas,
although everybody pays lip service to the idea that each #imported
.h corresponds exactly to a single class interface, in practice lots
of non-class bits get slipped in, and so we're back to being just a
dialect of C, with #import being like #include, but flakier.

Stan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]