Thanks for the feedback @stobot @etardiff.
With the latest updates, assignments like <$let a={{{ [all[tiddlers]] }}} >
will now create a multi-valued variable containing the complete results instead of the usual single valued variable. We therefore need to make sure that it always behave as a single valued variable for all existing usages of variables. That means that all of those existing usages cannot be changed.
In particular, the problem with allowing <myvar>
to return a result list instead of a single value is that it would mean that an assignment like the example above would no longer behave in the same way as at present: because it would now be interpreted as an assignment to a multi-valued variable, all the values would be retrieved by the <myvar>
syntax instead of just the first.
One way around these issues would be to introduce a new syntax for accessing multi-valued variables as operator operands. It seems like it might be useful: it would allow us to simply pass lists to user defined functions, and introduce much simpler list operations like combine, intersect etc.
The syntax would have to be a pair of one or more characters that can be used to quote the variable name. There aren’t many open/close character pairs that we haven’t used and that are easy to type on ordinary keyboards. The only obvious one is round brackets:
[my.function(multivaluedvarname),<anothervarname>,(anothermultivaluedvarname)]
That seems inconsistent with our existing usage of <varname>
. Another alternative would be to use double angle brackets:
[my.function<<multivaluedvarname>>,<anothervarname>,<<anothermultivaluedvarname>>]
Neither of these proposals is 100% backwards compatible, but it seems unlikely that anyone is using variable names that start with <
and end with >
, and so I wouldn’t think it would be a problem.
It might be worth mentioning a related idea that I have considered: to introduce quote symbols for using an entire sub filter as an operator operand. It’s obviously crazy because it leads to an even more unintelligible soup of similar looking symbols. For example:
[my.function{{{ [<something>addsuffix<anotherthing>] }}}]
Again, maddeningly, I don’t think we can do this with a significant break in backwards compatibility. The problem is essentially the same as above, but it can be restated in simpler terms. If myvar
was assigned as <$let a={{{ [all[tiddlers]] }}} >
then it would behind the scenes be a multivalued variable. The proposal here is that because the variable is multi-valued then the enlist
operator would return all the values in the variable, which would not be compatible with the existing usage which would take the first result in the list and treat it as a title list.
This case could be fixed with an explicit suffix to the enlist operator: enlist:all[]
perhaps, or enlist:multi[]
. However, that does seem a cop out, and rather undermines the goal of introducing as little new syntax as possible.
With the second proposal above of using double angle brackets to indicate access to a multi-valued variable, it would be possible to use [<<multivar>>]
within a filter to obtain the complete result list from a multi-valued variable.
Hmmm.