[mlpack-git] [mlpack/mlpack] Issue a fatal error when any ambiguous parameters are detected (#671)

Ryan Curtin notifications at github.com
Thu Jun 2 19:34:16 EDT 2016


The mlpack command-line programs use the `PARAM_STRING`, `PARAM_DOUBLE`, and other macros to define input parameters.  But it is possible that I could write:

```
PARAM_STRING("param1", "Parameter 1 documentation.", "p");
PARAM_STRING("param2", "Parameter 2 documentation.", "p");
```

You can see that `-p` now specifies two things. If you run the program and specify "-p", you will get an error like

``
option '-p' is ambiguous and matches '--param1' and '--param2'
```

But you only get that error when the option is specified.  So it is possible for a program writer to write a program with ambiguous options, test it (but not test every parameter), and not realize that there is a duplicate parameter.  I know this is true because I have done exactly that many times!

It should be possible, when options are registered, to catch this situation.  The `PARAM_*` macros expand to a global definition of a `mlpack::util::Option<>` object, which registers itself with the `mlpack::CLI` class.  I think that when options register, we should check to see that the short form of that option (and the long form) are not already specified, and if they are, we should call `Log::Fatal` with an error.

The relevant code can be found all in `src/mlpack/core/util/`.  I think this would be a good task for someone new to mlpack, so let me know if I can clarify anything.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/issues/671
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160602/ca09246c/attachment-0001.html>


More information about the mlpack-git mailing list