How do people feel about putting source compiler directives inside rdmd?

Jonathan Marler johnnymarler at
Tue Dec 3 16:45:52 UTC 2019

On Tuesday, 3 December 2019 at 14:01:07 UTC, bachmeier wrote:
> On Tuesday, 3 December 2019 at 09:46:59 UTC, Petar Kirov 
> [ZombineDev] wrote:
>> On the contrary. Without compiler directives or a tool that 
>> has them built-in, like dub or rdmd/rund you don't have any 
>> portability, because you have no idea how run build the 
>> script. It's ridiculous to expect just the right set 
>> dependencies to be magically installed on the system where the 
>> script will run.
> None of this is relevant if you have a tool that is limited to 
> running code that doesn't need compiler directives. I'm aware 
> that some people think you have to add every feature to every 
> tool. I disagree. Especially in cases where the functionality 
> is already provided by other tools.

This is true in most cases.  The problem is that some 
requirements of a D program can't be configured in the source 
file.  They can only be specified on the command-line.

For example, if you have a D program that requires -betterC, you 
couldn't declare this source file itself.  You can't specify 
import paths, versions and many other options in the source file.

Not all programs need to specify any of these options, but some 
do.  Here's an example of a D script that requires import paths, 
a version, betterC, and no dmd.conf file:

Without "Source Compiler Directives" this source file would not 
be able to declare the options that are required to build/run it 
correctly.  These requirements would need to be satisfied outside 
the source file itself, either through user intervention on the 
command-line or through some other tool.

Some D scripts have requirements that can only be specified via 
compiler flags.  I would rather have a way to specify these in 
the language but for now this feature solves the issue without 
having to make any big changes to the language.

More information about the Digitalmars-d mailing list