www.digitalmars.com         C & C++   DMDScript  

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

reply Timothee Cour <thelastmammoth gmail.com> writes:
Couldn't find a post on this so I'm asking here:
is there any reason why dmd chose to use this flag naming convention
in the first place?

-Dddocdir
-Dffilename
-Ipath
-offilename
(etc...)

vs a sane way, eg the one used in ldc2 (or many other unix tools,
which have a space at least as delimiter):

-Dd=docdir
-Df=filename
-I=path
-of=filename

The problem is:
* dmd's flags don't scale: now we can't have any new flag starting
with "-I" or "-L", etc as it would create conflicts. And I know some
people want to keep the number of flags to a minimum but that's not a
good reason to restrict future expansion ability
* it's visually harder to tell from the command line the options from
the arguments to these options.

If we don't deprecate in favor of the ldc2 style (is that an option
with a proper deprecation path?), can we at least make sure any future
flags will follow ldc2's convention?
Apr 10 2013
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 4/10/2013 11:20 AM, Timothee Cour wrote:
 Couldn't find a post on this so I'm asking here:
 is there any reason why dmd chose to use this flag naming convention
 in the first place?
 [...]

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.
Apr 10 2013
parent Jacob Carlborg <doob me.com> writes:
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.

Preferably the code for the new syntax should be in its own module/function and not included directly in "main". -- /Jacob Carlborg
Apr 10 2013
prev sibling next sibling parent reply "Jonas Drewsen" <nospam4321 hotmail.com > writes:
AFAIK most unix tools have two formats: long and short.

long:
dmd --foobar-dir=/somewhere/over/the/rainbow

short:
dmd -f /somewhere/over/the/rainbow

Most programs supports both. I think that would be the way to go.

/Jonas
Apr 11 2013
next sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-04-11 12:25, Jonas Drewsen wrote:
 AFAIK most unix tools have two formats: long and short.

 long:
 dmd --foobar-dir=/somewhere/over/the/rainbow

 short:
 dmd -f /somewhere/over/the/rainbow

 Most programs supports both. I think that would be the way to go.

For some reason compilers seem to only use a single dash for all formats. That is true for DMD, GCC and Clang. -- /Jacob Carlborg
Apr 11 2013
prev sibling parent Paulo Pinto <pjmlp progtools.org> writes:
Am 11.04.2013 17:20, schrieb John Colvin:
 On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:
 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo
Apr 11 2013
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:
 AFAIK most unix tools have two formats: long and short.

 long:
 dmd --foobar-dir=/somewhere/over/the/rainbow

 short:
 dmd -f /somewhere/over/the/rainbow

 Most programs supports both. I think that would be the way to go.

RDMD works on the assumption that its flags begin with -- and DMD's flags with -. There's no need to invent new short/long switches, we just need an equals sign to make it visually clear. Also using spaces might be a bad idea, you might end up doing the wrong thing if you call DMD incorrectly (e.g. a result of a wrong expansion in a shell script), for example: $ dmd -of foo.d bar.d Currently this is an error, the user forgot to specify the -of switch. If spaces were ok then this becomes the equivalent of: $ dmd -offoo.d bar.d I'd rather be safe than sorry and allow either -offoo or -of=foo. It will catch errors this way rather than do something unexpected.
Apr 11 2013
prev sibling next sibling parent "Jonas Drewsen" <nospam4321 hotmail.com > writes:
On Thursday, 11 April 2013 at 11:16:08 UTC, Andrej Mitrovic wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:
 AFAIK most unix tools have two formats: long and short.

 long:
 dmd --foobar-dir=/somewhere/over/the/rainbow

 short:
 dmd -f /somewhere/over/the/rainbow

 Most programs supports both. I think that would be the way to 
 go.

RDMD works on the assumption that its flags begin with -- and DMD's flags with -. There's no need to invent new short/long switches, we just need an equals sign to make it visually clear.

By "I think that would be the way to go" I did not necessary refer to having both formats supported at the same time but simply to use the standard way that people know.
 Also using spaces might be a bad idea, you might end up doing 
 the
 wrong thing if you call DMD incorrectly (e.g. a result of a 
 wrong
 expansion in a shell script), for example:

 $ dmd -of foo.d bar.d

 Currently this is an error, the user forgot to specify the -of 
 switch.
 If spaces were ok then this becomes the equivalent of:

 $ dmd -offoo.d bar.d

 I'd rather be safe than sorry and allow either -offoo or 
 -of=foo. It
 will catch errors this way rather than do something unexpected.

You may not like using spaces but it is a widespread standard and I think deviating is not the way to go. Anyway - this is turning into a bikeshed coloring discussion I guess :) /Jonas
Apr 11 2013
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:
 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.
Apr 11 2013
prev sibling next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:
 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.
Apr 11 2013
prev sibling next sibling parent Timothee Cour <thelastmammoth gmail.com> writes:
 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
Apr 12 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--047d7bdca7c205ef1604da26e2c7
Content-Type: text/plain; charset=ISO-8859-1

On 11 April 2013 17:57, Paulo Pinto <pjmlp progtools.org> wrote:

 Am 11.04.2013 17:20, schrieb John Colvin:

  On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:

 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo

Linux would have still taken off... and UNIX would still be relevant on the server market. :) -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --047d7bdca7c205ef1604da26e2c7 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 1= 1 April 2013 17:57, Paulo Pinto <span dir=3D"ltr">&lt;<a href=3D"mailto:pjm= lp progtools.org" target=3D"_blank">pjmlp progtools.org</a>&gt;</span> wrot= e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"> Am 11.04.2013 17:20, schrieb John Colvin:<div><div class=3D"h5"><br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> On 4/11/13, Jonas Drewsen &lt;<a href=3D"mailto:nospam4321 hotmail.com" tar= get=3D"_blank">nospam4321 hotmail.com</a>&gt; wrote:<br> <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p= x #ccc solid;padding-left:1ex"> By &quot;I think that would be the way to go&quot; I did not necessary<br> refer to having both formats supported at the same time but<br> simply to use the standard way that people know.<br> </blockquote> <br> Unix !=3D universal standard.<br> </blockquote> <br> Next best thing.<br> </blockquote> <br></div></div> Actually I would like to know how the desktop world would look like<br> had Apple bought BeOS instead.<br> <br> This would mean no UNIX on the desktop, assuming Apple would have<br> won a similar market as of today.<br> <br> --<br> Paulo<br> </blockquote></div><br></div><div class=3D"gmail_extra">Linux would have st= ill taken off... and UNIX would still be relevant on the server market.=A0 = :)<br clear=3D"all"></div><div class=3D"gmail_extra"><br>-- <br>Iain Buclaw= <br> <br>*(p &lt; e ? p++ : p) =3D (c &amp; 0x0f) + &#39;0&#39;; </div></div> --047d7bdca7c205ef1604da26e2c7--
Apr 12 2013
prev sibling next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 12 April 2013 at 09:54:30 UTC, Iain Buclaw wrote:
 On 11 April 2013 17:57, Paulo Pinto <pjmlp progtools.org> wrote:

 Am 11.04.2013 17:20, schrieb John Colvin:

  On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic 
 wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:

 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo

Linux would have still taken off... and UNIX would still be relevant on the server market. :)

Not to mention supercomputers. There's a reason why they use(d) UNIX and linux and it's not because of apple.
Apr 12 2013
prev sibling next sibling parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Friday, 12 April 2013 at 10:39:20 UTC, John Colvin wrote:
 On Friday, 12 April 2013 at 09:54:30 UTC, Iain Buclaw wrote:
 On 11 April 2013 17:57, Paulo Pinto <pjmlp progtools.org> 
 wrote:

 Am 11.04.2013 17:20, schrieb John Colvin:

 On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic 
 wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:

 By "I think that would be the way to go" I did not 
 necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo

Linux would have still taken off... and UNIX would still be relevant on the server market. :)

Not to mention supercomputers. There's a reason why they use(d) UNIX and linux and it's not because of apple.

Sure but I was speaking about the home market, not the server market. Then people would need to bash both Apple and Microsoft for not being UNIX like. Although I like UNIX architecture, it is not the be all end all of operating system architecture. I was lucky enough to play with various OS so far. -- Paulo
Apr 12 2013
prev sibling next sibling parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Friday, 12 April 2013 at 09:54:30 UTC, Iain Buclaw wrote:
 On 11 April 2013 17:57, Paulo Pinto <pjmlp progtools.org> wrote:

 Am 11.04.2013 17:20, schrieb John Colvin:

  On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic 
 wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:

 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo

Linux would have still taken off... and UNIX would still be relevant on the server market. :)

Linux took off because it provided a way to port UNIX software at cost zero. The companies where I developed in commercial UNIX platforms they only used Linux as a way to avoid paying UNIX licenses, not because Linux was something great. The enterprise world only cares about money. -- Paulo
Apr 12 2013
prev sibling next sibling parent "John Colvin" <john.loughran.colvin gmail.com> writes:
On Friday, 12 April 2013 at 12:12:18 UTC, Paulo Pinto wrote:
 On Friday, 12 April 2013 at 09:54:30 UTC, Iain Buclaw wrote:
 On 11 April 2013 17:57, Paulo Pinto <pjmlp progtools.org> 
 wrote:

 Am 11.04.2013 17:20, schrieb John Colvin:

 On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic 
 wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:

 By "I think that would be the way to go" I did not 
 necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo

Linux would have still taken off... and UNIX would still be relevant on the server market. :)

Linux took off because it provided a way to port UNIX software at cost zero. The companies where I developed in commercial UNIX platforms they only used Linux as a way to avoid paying UNIX licenses, not because Linux was something great. The enterprise world only cares about money. -- Paulo

I think we can probably agree that linux has become something quite great, despite that not being the initial reason for adoption. Even if you don't like the basic architecture that much, the community and frameworks built on top of it have been spectacular.
Apr 12 2013
prev sibling next sibling parent "Paulo Pinto" <pjmlp progtools.org> writes:
On Friday, 12 April 2013 at 12:19:09 UTC, John Colvin wrote:
 On Friday, 12 April 2013 at 12:12:18 UTC, Paulo Pinto wrote:
 On Friday, 12 April 2013 at 09:54:30 UTC, Iain Buclaw wrote:
 On 11 April 2013 17:57, Paulo Pinto <pjmlp progtools.org> 
 wrote:

 Am 11.04.2013 17:20, schrieb John Colvin:

 On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic 
 wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:

 By "I think that would be the way to go" I did not 
 necessary
 refer to having both formats supported at the same time 
 but
 simply to use the standard way that people know.

Unix != universal standard.

Next best thing.

Actually I would like to know how the desktop world would look like had Apple bought BeOS instead. This would mean no UNIX on the desktop, assuming Apple would have won a similar market as of today. -- Paulo

Linux would have still taken off... and UNIX would still be relevant on the server market. :)

Linux took off because it provided a way to port UNIX software at cost zero. The companies where I developed in commercial UNIX platforms they only used Linux as a way to avoid paying UNIX licenses, not because Linux was something great. The enterprise world only cares about money. -- Paulo

I think we can probably agree that linux has become something quite great, despite that not being the initial reason for adoption.

Fully agree, having access to Linux in 1995 allowed me to gain skills I could use while working on DG-UX, HP-UX, Aix and Solaris a few years later.
 Even if you don't like the basic architecture that much, the 
 community and frameworks built on top of it have been 
 spectacular.

Also fully agree. I only mean that the community should move beyond basic UNIX clones, even if many of the concepts stay. Plan9, Minix, Mach, Hurd, or something else. If we look at the application level for command line applications it has hardly changed since System V. -- Paulo
Apr 12 2013
prev sibling next sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 4/12/13, Timothee Cour <thelastmammoth gmail.com> wrote:
 3)
 can we deprecate the current behavior where one can pass the file name
 without extension (main vs main.d) as source?

I never understood the purpose of this feature, anyone know why it was added?
Apr 12 2013
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
On Thursday, 11 April 2013 at 15:15:09 UTC, Andrej Mitrovic wrote:
 On 4/11/13, Jonas Drewsen <nospam4321 hotmail.com> wrote:
 By "I think that would be the way to go" I did not necessary
 refer to having both formats supported at the same time but
 simply to use the standard way that people know.

Unix != universal standard.

Wasn't double hyphen introduced in GNU, not unix?
Apr 12 2013
prev sibling parent Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 4/12/13, Kagamin <spam here.lot> wrote:
 Wasn't double hyphen introduced in GNU, not unix?

I don't know but I don't like GNU conventions, especially their silly weirdo brace indentation style they use in GCC.
Apr 12 2013