Hello
I’ve been playing around with using functions at various levels, and I came across some behaviour which I’m not sure about - it could be intended, or it could be a bug, or there could just be something I’m missing.
From what I can tell, if a function definition uses the currentTiddler
variable, and then that function is invoked in an environment where there would normally be a temporarily different currentTiddler
and the existing currentTiddler
would become ..currentTiddler
(e.g. inside filter runs with the map prefix, or within subfilters), the function seems to ignore this reassignment and return ..currentTiddler
when you call currentTiddler
, and nothing when you call ..currentTiddler
.
See example code below:
\function .returnCurrent() [<currentTiddler>!is[blank]else[NA]]
\function .return..Current() [<..currentTiddler>!is[blank]else[NA]]
<$tiddler tiddler="outer">
testing functions in "outer" tiddler:
<<.returnCurrent>>
<<.return..Current>>
testing function inside map prefix:
{{{ inner :map[<.returnCurrent>] }}}
{{{ inner :map[<.return..Current>] }}}
testing subfilter:
<$let subfilter="""[<.returnCurrent>] [<.return..Current>]""">
{{{ [[inner]subfilter<subfilter>] }}}
</$let>
</$tiddler>
All three of these tests seem to return the sequence “Outer NA” for me, despite the fact that I would expect the 2nd and 3rd tests to return “Inner Outer” instead.
Does anyone know if this is intended behaviour, or if there is something I’m missing here?
Thanks for reading