What Magic is Behind MacroCall?

  1. Open https://tiddlywiki.com
  2. Create a tiddler with below contents and tag it with $:/tags/Macro
\define myfun(src) <$macrocall $name="__src__" />
  1. Save
  2. In another tiddler do below experiments
<<myfun "Hello">>

It produces:

Hello

Now

<<myfun src:"""
\define magic() I am a beautiful angel!
Hey, <<magic>>
""" >>

It produces:

Hey, I am a beautiful angel!

What magic is behid macrocall with "__src__" ? If you use \define myfun(src) <$macrocall $name=<<__src__>> /> no magic you will see!

Macros and variables share some similarities, like you call/access them the same way. I think it’s possible that macros are just implemented as special variables or vice versa.

Since macro parameters can be accessed as variables when surrounded by double underscores, \define myfun(src) <$macrocall $name="__src__" /> is pretty much the same as \define myfun(src) <<__src__>>.

2 Likes

Correct. Macros are just variables with text substitution support.

1 Like

Note that, this way I can embed a PRIVATE macro definition everywhere in my tiddler just by calling myfun above!