When I try the above on the preview site, I get Filter error: Missing [ in filter expression
. If I change it to [my.function(multivaluedvarname),<anothervarname>,[a constant]]
then I don’t get any error (displays all tiddler titles since my.function is undefined). Maybe the current code is only handling the parens syntax for the first argument?
I’m trying the above because I’m skeptical about using special syntax for this. To me it seems better to use an operator to handle the MVV (though difficult to come up with a good name for it).
Unless I misunderstand the code, in order for any javascript operator to make use of an MVV, code has to be explicitly added as you’ve done for the title
operator (i.e. [(myvar)]
is shorthand for [title(myvar)]
).
Do you envision use cases beyond just the title
operator for this? If so then will the special case code be added? If not, then it seem like a very big decision to lock in new syntax for not much gain.
Maybe there are gains to be had with this syntax and user defined functions? That’s why I was trying the syntax I quoted from your post. To try to understand the benefits from the user defined function perspective.
Adding this as an operator would involve much less “lock in”. In fact, even with the special syntax, a dedicated operator might still be worthwhile since an operator can have variables as arguments.
Contrived example:
function concat.vars(a1, a2, a3)
[varlist<a1>] :all[varlist<a2>] :all[varlist<a3>]
\end
{{{ a b c :let[[v1]] [concat.vars[v1],[v1],[v1]] }}}
=> a b c a b c a b c
Did you consider the possibility of implementing let
as an operator rather than a filter run prefix?