[RFC] `$` with default value
I have many chances to write the -Q expression.
I found I had to write $ with a fallback value to make readtags run without error:
(or ($ "properties") "")
($ "properties" "")
(or $extras "")
To make the expressions shorter, I want to add a short-hand variant for these expressions:
($: "properties")
$:extras
@AmaiKinono, you have a lot of experience in this area. Could you give me comments?
The proposed $: operator is handy if the empty string is a reasonable fallback value in most situations. But I may not have enough experience to answer this, as Citre uses another strategy.
Say we are given an expression (eq? $name "foo"). Citre scans all field name symbols in it, and add an explicit check in the generated filter:
(and $name (eq? $name "foo"))
So the expression returns false if $name is missing. And, if we require Citre to keep the lines with missing fields, it generates:
(or (not $name) (eq? $name "foo"))
So the concept of fallback value is not used. See citre-readtags-regexp-quote for details.