<<filter>> vs [<filter>]

83 views
Skip to first unread message

Mat

unread,
Jul 8, 2019, 9:03:21 AM7/8/19
to tiddl...@googlegroups.com
[Edit: I added "enlist"]

Anyone who know is well familiar with the underlying intricacies of TW:

<$set name=myfilter filter="[tag[foo]]">

<$list filter=<
<myfilter>> > ...
or
<$list filter="""[enlist
<myfilter>]"""> ...

Of course, only the second would allow for additional operators to be added but other than that, are they functionally equivalent?

If not, when is either appropriate?

<:-)

Jed Carty

unread,
Jul 8, 2019, 9:50:48 AM7/8/19
to TiddlyWiki
filter=<<foo>> uses whatever is stored in the variable foo as the filter itself, filter=[<foo>] uses whatever is stored in the variable foo as an input title.

Some examples are probably more helpful:

<$set name=foo value="""[tag[HelloThere]]""">

Set `foo="[tag[HelloThere]]"`

! Using `"[<foo>]"`

<$list filter="[<foo>]">

</$list>

! Using `<<foo>>`

<$list filter=<<foo>>>

</$list>

</$set>


This lets you build filters using [<foo>] and then use that filter using <<foo>>

PMario

unread,
Jul 8, 2019, 10:01:35 AM7/8/19
to TiddlyWiki
Hi Mat,

If we only look at the the <$list line, they are fundamentally different.

The first one assigns a macro-call to the filter variable
The second one assigns a string value to the filter variable.

The first list needs to run 2 filters. 1 in the set widget 1 in the list widget

The second list needs to run only 1 filter .. which shuld be faster as calling a macro and run 2 filters


If you open the https://tiddlywiki.com/prerelease/ and paste this code:

\whitespace trim

<$set name=myfilter filter="[tag[foo]]">

<$list filter=<<myfilter>> />

<$list filter="""[<myfilter>]"""/
>
</$set>

Activate the preview: Parse Tree
You can see the result is very simlar. See the macro-call

Activate the preview: Widget Tree
The result is different.

--------------------

Open close the preview several times ....
F12 ... open dev consule
select the "Console" tab
click the "bin" button to clear the output

type: $tw.perf.log()

which will open the filter log. .... The filter a should be around line 40   .... filter [<myfilter>] is around line 80

This suggests, the second one is faster. ... I'm not sure if the new filter optimizer is responsible for this.

have fun!
mario

Mat

unread,
Jul 8, 2019, 10:33:46 AM7/8/19
to TiddlyWiki
Great answers guys!

I missed to include the "enlist" operator (now added in the OP) but I assume this doesn't change @pmarios point that it is still generally faster.

>Open close the preview several times .... 

Trickyyyy!

<:-)

Watt

unread,
Jul 8, 2019, 10:45:17 AM7/8/19
to TiddlyWiki
I hope you twizards know how much your contributions are valued and appreciated but on behalf of non-programmers everywhere, the easily confused and all those unfamiliar with the use and tradition behind the word 'foo' can I humbly request that it is never used in examples relating to tiddlywiki? It really doesn't make things easier to understand.

And as for 'bar'... please, don't do it.

https://en.m.wikipedia.org/wiki/Foobar

Mat

unread,
Jul 8, 2019, 11:20:34 AM7/8/19
to TiddlyWiki
@Watt 


Foo, foobar etc was invented specifically so you don't have to think. Plus it is now a convention so if you introduce something else, then people will have to get used to that instead. For a single string I guess HelloThere would work but it is not generic. And for multiple strings... it is annoyingliy difficult to come up with anything that is not asdfasdöghhagsöj which is also not good. Besides, bars can be nice.

In the docs I do thing we avoid Foo though.

<:-)

Mat

unread,
Jul 8, 2019, 11:23:09 AM7/8/19
to TiddlyWiki
Addendum: And any newcomers who have a modicum of programming knowledge will use Foo anyway so... it's probably better to just learn it. IMO it is part of common computer literacy.

<:-)

Watt

unread,
Jul 8, 2019, 12:18:45 PM7/8/19
to TiddlyWiki
Has my plea been footile? It has just the opposite effect on me, I can't stop thinking 'what's a foo?' I must be foolexic, or was on a bar stool the day they covered it at school. Couldn't 'apples' be used instead?

Mat

unread,
Jul 8, 2019, 12:21:51 PM7/8/19
to TiddlyWiki
I'm actually allergic to apples. 
...but I must admit, that IS a nice alternative. I might start to use it :-)

<:-)

TonyM

unread,
Jul 8, 2019, 8:13:54 PM7/8/19
to TiddlyWiki
Mat,

Is the origin of Foo bar from the "Grand Foo Bar" from a masonic lodge? a very U.S. centric source?. I also find it all but useless myself, I have to read something 5 times if it has too many foos and bars because there is not any other information contained within them. The fact that someone does not need to think to use foo bar belies that fact, I can see that a little more thinking would have being helpful. It may appear to make sense to the writer, but I suspect it is often more confusing for the reader.

Over the years I have used consistent examples like Fred, Alice and Bob, Fruits and number suffixes number-1 or "if-true" var-1, input etc.... I understand Foo and Bar but find it the least helpful of the bunch.

Watts funny lines struck a chord.
Has my plea been footile? It has just the opposite effect on me, I can't stop thinking 'what's a foo?' I must be foolexic, or was on a bar stool the day they covered it at school. Couldn't 'apples' be used instead?


just saying..

Regards
Tony
Reply all
Reply to author
Forward
0 new messages