Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] $ with default value #4076

Open
masatake opened this issue Sep 13, 2024 · 1 comment
Open

[RFC] $ with default value #4076

masatake opened this issue Sep 13, 2024 · 1 comment

Comments

@masatake
Copy link
Member

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?

@AmaiKinono
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants