[Swift-devel] Re: Import Statement

Ben Clifford benc at hawaga.org.uk
Fri Jul 9 02:49:43 CDT 2010


My original implementation was, I think, to try to get something in the 
langauge that was better than running .swift files through cpp.

There is no module or namespace structure in Swift, so using something 
based on filenames makes sense.

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.

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)

-- 



More information about the Swift-devel mailing list