import concerns (was Re: Historical language survey)

Kirk McDonald kirklin.mcdonald at gmail.com
Sat Jul 8 19:21:51 PDT 2006


Kirk McDonald wrote:
> import B with bar;
> bar(); // unambiguous
> 
> The point is you can list multiple names from the module without 
> repeating the module name:
> 
> import MyModule with foo, baz;
> 
> And "with" is already a keyword.
> 

To put this another way (forgive any errors in my syntax, I'm not used 
to it):

ImportDeclaration:
	import ModuleNameList ;

ModuleNameList:
	ModuleNameAliasWith
	ModuleNameAlias , ModuleNameList

ModuleNameAliasWith
	ModuleNameAlias
	ModuleNameAlias with IdentifierAliasList

ModuleNameAlias:
	ModuleName
	ModuleName alias Identifier

IdentifierAliasList:
	IdentifierAlias
	IdentifierAlias , IdentifierAliasList

IdentifierAlias:
	Identifier
	Identifier alias Identifier

Note that this means that as soon as "with" is used, you cannot specify 
any more modules in that import statement:

// Imports modules foo, bar, and baz, and aliases
// baz.a, baz.b, and baz.c
import foo, bar, baz with a, b, c;

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki



More information about the Digitalmars-d mailing list