4 ms·
> It just allows you to logically separate build time I/O from runtime I/O, which I find is nice for reproducibility of builds and maintainability of code. Yo
by nicwilson 7y ago
> It just allows you to logically separate build time I/O from runtime I/O, which I find is nice for reproducibility of builds and maintainability of code.
You can get the same effect if you really need it with a pre-build command with dub (the package manager/build tool, and with other build tools such as reggae), but compilation is supposed to not change the state of the system other than produce build artefacts, you can read files at compile time with `import("filename")`, but you can't write to files, or open sockets etc.
Things like mixing in a data file is incredibly useful and not something I would want to use a rebuild step for at all.
> Is it compatible with 100% of the code that the current DMD release is compatible with? That’s all I ask for in alternate compiler implementations... but it seems like a lot, sometimes.
Not strictly.
It is usually pickier about what is deems valid (which is usually corner cases that DMD really ought to reject). They share the same frontend so there is very little difference.
It has some of its own bugs, though nothing too major.
It generally has way less bugs both due to its release cycle being based off of DMD stable and thus it lags one cycle behind (~six weeks), so new features aren't available immediately, and having all the backend and optimisation handled by LLVM, though we occasionally hit LLVM bugs that clang for some reason does not seem to trigger.
(I develop both DMD and LDC (the LLVM based D compiler))
- coder543 7y ago> Things like mixing in a data file is incredibly useful and not something I would want to use a rebuild step for at all. It’s not directly part of the const function, but rust has compiler built-ins to import files as values as compile time, which makes it easy to declare global static variables that contain that data. This is different from being able to walk a directory and read random files. https://doc.rust-lang.org/std/macro.include_str.html https://doc.rust-lang.org/std/macro.include_str.html https://doc.rust-lang.org/std/macro.include_bytes.html https://doc.rust-lang.org/std/macro.include_bytes.html > They share the same frontend so there is very little difference. That’s excellent.
- EvenThisAcronym 7y ago> This is different from being able to walk a directory and read random files. D doesn't allow you to do that either. You have to specify what files you are importing via a compiler switch: https://dlang.org/spec/expression.html#import_expressions https://dlang.org/spec/expression.html#import_expressions
- WalterBright 7y agoYes. That's another barrier I put in to prevent a carefully crafted source code from being a malware vector.