Filter + macro quirks

For the below tiddler:

\define mac1()  
<$let fldnameprefix="ok">yes</$let>
\end

\define mac2() yes

ii-<<mac1>>-ii <br>
oo-<<mac2>>-oo <br>

qq-{{{ [<mac2>match[yes]then[matched]] }}}-qq <br>
pp-{{{ [<mac1>match[yes]then[matched]] }}}-pp <br>

generates an output :

ii-yes-ii
oo-yes-oo

qq-matched-qq
pp--pp

Both macros mac1 and mac2 generate an identical output of yes.
Yet, why would the last line of the wikitext filter not match the output of macro mac1?

When <<mac1>> occurs in wikitext, it’s content is first inserted into the wikitext, and then the wikitext is parsed/rendered. Thus, because mac1 is defined as

<$let fldnameprefix="ok">yes</$let>

the wikitext

ii-<<mac1>>-ii

is expanded to

ii-<$let fldnameprefix="ok">yes</$let>-ii

which is then “wikified” (parsed/rendered) as

ii-yes-ii

However, when <mac1> occurs in a filter

pp-{{{ [<mac1>match[yes]then[matched]] }}}-pp

is expanded to

pp-{{{ [[<$let fldnameprefix="ok">yes</$let>]match[yes]then[matched]] }}}-pp

but literal filter values are NOT automatically wikified, but are instead just used as-is… and thus the <mac1> macro output does not match yes, so the filter result is null and “matched” is not displayed.

To use the rendered output of the macro within the filter syntax, you can first use the $wikify widget to convert the macro output, like this:

<$wikify name="mac1" text=<<mac1>>>
pp-{{{ [<mac1>match[yes]then[matched]] }}}-pp <br>
</$wikify>

hope this helps,
-e

I did not understand this part.
What, in above, is a “literal filter value” ?

So is the filter trying to match "[<$let fldnameprefix="ok">yes</$let>]" with "yes" ?
When you say “NOT automatically wikified”, does it mean "[<$let fldnameprefix="ok">yes</$let>]" is not wikified because it occurs inside a filter ?

And the various documentations around seem to suggest that $wikify is “expensive” to use. So is there a better way to get the above done ?

That’s correct… and to be exact, the filter is trying to match “<$let fldnameprefix="ok">yes</$let>” with “yes”. The square brackets surrounding those values mean they are “literal filter values” as compared with angle brackets which indicate variable or macro references, or curly braces which indicate tiddler field references.

Processing a $wikify widget CAN be “expensive”, depending upon the content being wikified, and whether or not the $wikify widget occurs within the inner content of a $list widget (i.e., a repeating loop), where it will be invoked for each matching list item. If you are processing 1000s of list items, the overhead can add up. However, for simple uses, while its performance is not highly optimized, it’s also not particularly costly. I would say “go ahead and use it” and only look for alternatives if things start to take a long time to process.