dmd command line options bad design: -offilename, -Ddocdir etc.

Timothee Cour thelastmammoth at gmail.com
Fri Apr 12 02:50:00 PDT 2013


> On 2013-04-10 21:30, Walter Bright wrote:
> I agree. The way to do it is to support both the old and the new ways for now. Anyone want to do a pull req?
> Also, this should be put in bugzilla as an enhancement request.

Let's agree on specifics before writing enhancement request, and
possibly make a single one-time breaking change instead of several
short-sighted ones.

With type A being -offilename and type B being -of=filename, how about:

1)
prevent any newly created flags of type A

2)
migrate all A flags to B flags. Here's one possible way to achieve
this (say in next dmd release):

dmd -offilename main.d //works but generates a warning for now, and
error after a certain time passed
dmd -old_flag -offilename main.d //works and doesn't generate a warning.
dmd -new_flag -of=filename main.d //works. After a certain time
passed, -new_flag is implied

Note, A and B flags can't be mixed, eg: -offilename -Ddoc=dir will
give error, in all 3 cases above (ie for flags that are currently in
the A style).

2b) Alternative: use a new binary name (dmd2) instead of -newflag. I
don't like this as much somehow.

3)
can we deprecate the current behavior where one can pass the file name
without extension (main vs main.d) as source? Consistency is better
than avoiding to type those 2 characters. I created a pathological
case with main.d is conflicting with main.d.d (with different
contents). Which one do you think is called when we call rdmd main.d ?
Note, I raised a very analogous concern here
https://github.com/D-Programming-Language/dmd/pull/1871#issuecomment-16101987
regarding naming of object files in a flat hierarchy (see my example
with dmd -c -oq foo/mod.d foo_mod.d)

4)
The current strategy of rdmd is to treat as input arguments anything
after the first source file:
rdmd main.d myfirstprogramarg // a bit awkward, especially with
optional extension it gets hard to parse visually.

This is error prone, and inconsistent with dmd's behavior, which is:
dmd src1.d -run main.d myfirstprogramarg //a bit awkward, need to
split the source from the main file.

I suggest instead something simpler, explicit and consistent, using
-args as a dmd command line argument, that would just work as well
with rdmd:

dmd main.d src1.d -args myfirstprogramarg
rdmd main.d -args myfirstprogramarg


5)
currently we distinguish rdmd's arguments from dmd's arguments via
'--' vs '-'. A better way IMO would be to have a special flag
indicating the start of dmd's (or gdc/ldc...) flags: eg
rdmd --chatty --dflags -version=myversion main.d


Timothee Cour


More information about the Digitalmars-d mailing list