Issue507

Title option parser: make keywords mandatory
Priority wish Status resolved
Superseder Nosy List florian, jendrik, malte
Assigned To Keywords
Optional summary
part of issue588

Created on 2015-01-04.17:58:13 by jendrik, last changed by malte.

Summary
part of issue588
Messages
msg11179 (view) Author: malte Date: 2023-07-25.10:54:52
This wish has sat for eight years, and I don't remember anyone made a push to implement this in this time. I am therefore closing it as "looks like we're not gonna do it".

I remain somewhat sympathetic to the idea, but it would require an active implementation effort, and one can always make an argument that if you want to use keyword arguments, just use them.

Of course if someone feels strongly about this, they can revive the idea and try to convince us that we want this. :-)
msg6166 (view) Author: florian Date: 2017-03-09.20:42:50
The bug is now issue711.
msg6164 (view) Author: malte Date: 2017-03-09.15:45:22
Unlike Jendrik's example, where ff() matches the first positional argument and
cea() the second one, this example should really be an error, as "max" only
takes a single argument.

Do we silently swallow additional arguments? It looks like we do, at least for
max(), but probably across the board. This is a bug different from the wish in
this issue, and it would be great if you could open an issue for it mentioning
the "max(h1, h2)" example. Here is an example of something that the option
parser accepts but shouldn't:

./fast-downward.py ../benchmarks/blocks/probBLOCKS-4-0.pddl --search
"astar(max(ff(), cea()))"
msg6163 (view) Author: florian Date: 2017-03-09.09:21:59
Another tricky example for this is "max(h1, h2)" which actually computes
max([h1]) = h1.
msg3992 (view) Author: jendrik Date: 2015-01-04.17:58:13
Originally this issue was posted in the discussion of issue288, but we decided to split it off into a separate 
issue.


Jendrik originally posted:

We stumbled over a parser subtlety. I'll use a config that is present 
in the master branch to demonstrate:

When a user wants to run lazy_greedy with ff() and cea() he might forget the 
square brackets:

./downward-release --search "lazy_greedy(ff(), cea())"

The parser happily accepts this and cea() is used to calculate preferred 
operators. We should maybe think about ways to prevent such subtle usage 
errors.


Malte commented:

If we want to borrow additional ideas from Python, Python has "keyword-only"
arguments, which also solve the problem of not changing meaning if additional
options are added. For the large majority of options, we by convention always
use the keyword form anyway. Depending on the type of object, we usually use the
non-keyword positional form only for 0-1 arguments. Maybe keyword-only should be
the default and possibly positional arguments should be the special case.
History
Date User Action Args
2023-07-25 10:54:52maltesetstatus: chatting -> resolved
messages: + msg11179
2021-03-18 14:21:02jendriksetsummary: part of issue588
2017-04-21 18:13:28jendriksettitle: avoid subtle usage errors by making parser more rigorous -> option parser: make keywords mandatory
2017-03-09 20:42:50floriansetmessages: + msg6166
2017-03-09 15:45:22maltesetmessages: + msg6164
2017-03-09 09:21:59floriansetstatus: unread -> chatting
nosy: + florian
messages: + msg6163
2015-01-04 17:58:13jendrikcreate