I was wondering about the scope of macro definitions ...
The scope of a macro appears to be 'in the current tiddler where it was defined
or any tiddler transcluded from the current tiddler'
Here are two tiddlers
Tiddler1Test is
\define foo()
say bar
\end
in tiddler 1 foo=<<foo>>
{{Tiddler2Test}}
Tiddler2Test is
in tiddler 2 foo = <<foo>>
Tiddler1 renders as
in tiddler 1 foo=say bar
in tiddler 2 foo = say bar
Which means the transclusion of Tiddler2 sees the macro - BUT
Tiddler2 viewed at the top level does NOT SEE the macro and renders as
in tiddler 2 foo =
So how {{Tiddler2Test}} expands is dependent upon the context - so my explanation
of transclusion "it's like a spreadsheet" is not really true. It's like a spreadsheet but including
a cell from different places is not guaranteed to produce the same result.
Up to now, my expectation was that {{X}} always expanded to the same thing until the end
of the universe and not depending upon where it was called from.
Is the moral "don't use macros outside the tiddler where they were defined" or what should I be doing.
I seem to have broken some law of tiddly programming in the "thou shalt not ...." and ended up in the
"there will be gnashing of teeth and gnawing of bones" part of the system.
Cheers
/Joe