[Swift-devel] Re: Import Statement

Michael Wilde wilde at mcs.anl.gov
Fri Jul 9 11:08:55 CDT 2010


----- "Ben Clifford" <benc at hawaga.org.uk> wrote:

> 
> The requirement to have imports right at the start probably comes from
> me 
> wanting to import the source code of the included file fairly early in
> 
> processing. If you allow import statements elsewhere, then there is a
> 
> question of "why?" - what behaviour do you expect to be different?
> 
> If its to allow import statements to appear anywhere, but have them
> mean 
> the same thing no matter where they appear, then I think it should be
> 
> fairly straightforward to make them work.

It was to enable them to appear anywhere for textual purposes.
The semantics of same behavior regardless where they appear sounds good.

> I think nested includes won't work correctly in the present 
> implementation:
> 
>   myprog imports useful lib. myprogr imports stdlib. usefullib imports
> 
>   stdlib.
> 
> I think that will give you duplicate imports which will break things.
> 
> That's probably not hard to resolve (eg. check if a particular lib has
> 
> been imported and skip it - don't start doing wierd cpp style ifdefs)

That seems worth doing at some point. For now Jon's initial enhancement of path names will be useful and sufficient.

- Mike




More information about the Swift-devel mailing list