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 





-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywikidev+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywikidev@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/90b1c94f-09a7-4a8b-a0aa-10adc64a9898%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to