ghc command line arguments parsing

Harendra Kumar harendra.kumar at gmail.com
Fri Aug 19 12:06:23 UTC 2016


On 19 August 2016 at 14:42, Sven Panne <svenpanne at gmail.com> wrote:

>
> Hmmm, do we need '--ghc-args=' at all when we have '--' as the border
> between the 2 "argument worlds"? Without thinking too much about it, :-} I
> guess we don't. This would be consistent with how e.g. "stack exec" or
> "gdb" work. An explicit option --pass-this-to-some-progXY is only needed
> when there are more than 2 "argument worlds" involved, otherwise '--' is
> enough, and also easier to type/remember.
>

Hmm, I have been there :-) There is a slight gotcha here. This is how the
runghc command looks like:

runghc [runghc flags] [--] [GHC flags] progname [prog args]

The regular '--' separation works well when we have only two worlds; we
consume upto '--' and give the rest opaquely to the other one. Here we have
three  scopes, we need to separate runghc flags, GHC flags, program and its
args. In the above command we cannot distinguish a GHC arg from progname.

One way to solve that is to put another mandatory '--' after the GHC flags
so that GHC flags are always delimited. With that here are the valid forms
of the command:

1) runghc [runghc flags] progname [prog args]

2) runghc [runghc flags] -- progname [prog args]
3) runghc [runghc flags] -- [GHC flags] -- progname [prog args]

For simplicity we will only pass GHC args using the 3rd form of the command
even if they are not conflicting with runghc flags. Note that these changes
will be incompatible with the previous implementation. Does this sound ok?
Or we keep the good old '--ghc-arg='?

-harendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20160819/0b90036a/attachment.html>


More information about the ghc-devs mailing list