On Tuesday, September 15, 2020 at 3:00:33 PM UTC-7, Dr Bob Jansen wrote:
>
> One question. You reference the macro parameter using multiple braces but 
> the documentation says to use <<__...__>>. Is this documented somewhere?
>

The "multiple braces" isn't the reference to the macro parameter.  It's a 
"filtered transclusion", which in this case enables use of the filter 
syntax to compute a value and then store it in a variable
(see https://tiddlywiki.com/#Transclusion%20in%20WikiText)

Then, within that filter, I am using the $argname$ "placeholder" syntax, 
surrounded by "[...]" to insert the macro parameter value directly into the 
filter.
(see https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText, 
"Accessing variables and parameters")

Note that "<<__...__>>" is an alternative method of accessing a macro 
parameter ("parameter-as-variable") that is useful in places where a 
variable reference is normally used, while the "placeholder" syntax works 
by direct text substitution of the parameter's value into the surrounding 
syntax.  This substitution occurs before any of the macro's code is 
invoked, and thus can be used *anywhere* inside the macro, regardless of 
the context in which it occurs.

An example of the difference between these two methods would be 
concatenation of values.  For instance, using placeholders, we can join 
arguments together like this:
\define fullname(first,last) $first$ $last$
The result (the combined argument text) is then the "return" value of the 
macro, and can then be displayed as output or used as a widget parameter.

In contrast:
\define fullname(first,last) <<__first__>> <<__last__>>
Would not work, since the macro simply returns the content as shown, 
without any substitution, so it can't be used to display output, nor as a 
widget parameter because the <<__...__>> syntax is only recognized *within* 
a macro.

I very rarely make use of the <<__...__>> syntax, and when I *need* to make 
a variable from a macro parameter, I use an explicit $vars widget, like 
this:
<$vars varname="$param$>
The only time I use the "parameters-as-variables" syntax is to "help avoid 
issues with parameters that contain quotes", as described here:
https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText, "Parameters as 
variables"

Hope this helps...

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/cbae2bd3-3cd9-476a-90dd-88f6c11a1d18o%40googlegroups.com.

Reply via email to