DIP81: Writing files at compile time

JDemler via Digitalmars-d digitalmars-d at puremagic.com
Thu Aug 13 02:52:01 PDT 2015


On Thursday, 13 August 2015 at 08:19:15 UTC, Ola Fosheim Grøstad 
wrote:
> On Thursday, 13 August 2015 at 00:54:37 UTC, JDemler wrote:
>> I am not sure if I understand your idea correctly:
>> The compiler would in case of an export(name, content) write 
>> the content both to a internal database and the filesystem and 
>> then only use the internal one?
>> Or could the content of the internal database be copied to the 
>> file system at the end of the compilation process? Or is only 
>> the output bundle written to the file system?
>
> The filesystem is a compiler issue and not a language issue, so 
> sure, the compiler could do whatever it wants, flush everything 
> to disk or into a SQL database or…
>
> Keep in mind that someone might want to compile on a diskless 
> computer from an in-memory zip-file or similar.
>
> I think the important file generation that are relevant to the 
> language would be for the output bundle, so that you e.g. can 
> have a config file in D and generate platform specific files 
> (.ini, .xml etc).

To summarize:
We would have a central registry handling all the generated and 
non generated files.
If an import is triggered, this registry is then searched for the 
imported file. If this file does not already exist, the import 
blocks. Writing these generated files to the file system would be 
optional, triggered by a compiler switch and happen after the 
compilation process is complete.

This solves the concurrency problem. But what about non 
concurrent compiler runs? A block there would never be resolved. 
I do not know enough about compilers to judge this problem. Can a 
sane way of compiling the files be found easily? Can the compiler 
switch to compile something else when it is blocked on an import?

And I do not understand why you differentiate between generated 
source files and generated non source files (.xml, .ini). As both 
types can be imported (or read at compile time) I do not think we 
should treat them differently. Also we would need a way to tell 
the one from the other (file extension? different parameter in 
the export syntax?).
In my understanding storage area 2 and 3 should be merged.


More information about the Digitalmars-d mailing list