Convert string to labelled option argument


I’m working on a query parser and I’m wondering if it’s possible to send a parsed string as a labelled arguments. So for example if we have

then the query parser would parse “id” and the value 5. Would it be possible then to convert that to send it in as a labelled argument for a function so that f(~id=5)? and if the string wouldn’t match any arguments then it would be ignored.


The closest I can think of is to make id an optional labelled parameter, then parse id from the query string as an optional value. Then you directly pass it into the function: f(?id, ...)


Wouldn’t order matter then? If we have something like


then if order matter we have to ensure that author goes as the first argument and then year as the second. Which means that we have to sort in the parser. If we can send in the labelled argument author=M then that would mean no manual sorting is needed.