From previuous tiddlers I understood that in a filter .myfunction[]
is equal to <.myfunction>
.
And then I thought that it would mean that all[]
would be the same as <all>
. Which is not the case, but this is a little bit annoying that our beloved syntax as such discrepancies.
Whtever, in fact, my concern was about a filter function argument. I can code easily for “take the default input, but if it is void take the parameter, but if itself is void, take the current tiddler” as initial input. (by void, I mean satisfying is[blank]
:
\define myfunction(arg) [all[]!is[blank]else<arg>!is[blank]else<currentTiddler>.doYourWill[]]
But what if I want “take the parameter, but if it is void take the default input, but if itself is void, take the current tiddler” as initial input?
I can’t build that with the same logic, if only beacause it would alter the default input! Instead, I wish I could code it like that.
\define myfunction2(arg) [all[]unless<arg>!is[blank]else<currentTiddler>.doYourWill[]]
where unless
would swap the input with its argument if tha latter is not blank. This filter operator would have to be coded in javascript. I can do that, this is not my question.
My question is: would other people be interested in such a filter operator?
Do you see a way to achieve the same behaviour that could be coded withou that new filter operator?