What is "stringImportPaths"

Jacob Carlborg doob at me.com
Thu Dec 7 09:47:31 UTC 2017


On 2017-12-06 20:05, mrphobby wrote:
> Can anyone explain what "stringImportPaths" is? I have seen this being 
> used in dub.json files and I think I kind of know what it does, but I 
> haven't been able to find a clear explanation in any documentation of 
> what it does. It does not look like anything I'm familiar with from 
> other languages.
> 
> I understand it can be used for resources but I have seen it being used 
> with both text files and binary files so I'm a bit confused. The 
> documentation says I can import "whatever", but that feels a bit weird 
> since importing is a construct used for importing symbols, right?

There are two kinds of language constructs that uses the "import" 
keyword. One is the "Import Declaration" [1] which is the most common 
one and is used to import other symbols. The other language construct is 
the "Import Expression" [2], which is used to read a file at compile 
time and put its content into a string literal in your source code.

Anything specified to the "stringImportPaths" build setting will be sent 
to the compiler with the -J flag.

[1] https://dlang.org/spec/module.html#ImportDeclaration
[2] https://dlang.org/spec/expression.html#import_expressions

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list