Is there an advantage of using "$param$" instead of <<__param__>> and "$(nonlocalvar)$" instead of <<nonlocalvar>> ? #6332
-
Hi people, I have a question. Macro Definitions in WikiText documents four types of variables: It seems
Greetings, Nils |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 12 replies
-
I just see, they seem to be substituted at different points in time. |
Beta Was this translation helpful? Give feedback.
-
I am starting to grasp it
I am not sure if I like this. |
Beta Was this translation helpful? Give feedback.
-
Evolution.
Partially yes,
If the macro is called with The same is true for
As I wrote Technically macro definition and variables are almost the same thing. eg: Hope that helps. |
Beta Was this translation helpful? Give feedback.
-
The history was roughly in the following order. Macros were first implemented with parameters based on text substitution (ie, the The weakness of that approach became clear very quickly. For a long time the core had problems with tiddler titles that ended in double quotes because of situations like this:
There are situations where text substitution is a good mental model: assembling URLs or tiddler titles from fragments are good examples. Back to the history: next we implemented the Much, much later, about 2018 I believe, we added the
Broadly. It's better to think of macros in two different ways:
See above! Perhaps some of the above might be usefully folded into the docs? @btheado – might you kindly be able to have a look at this? |
Beta Was this translation helpful? Give feedback.
-
Sure, I can take a look. |
Beta Was this translation helpful? Give feedback.
Hi @nilslindemann
The history was roughly in the following order.
Macros were first implemented with parameters based on text substitution (ie, the
$param$
syntax). The implementation was and is very simple: before using the value of the macro a search and replace is performed for each specified$param$
with the corresponding value (the value specified when invoking the macro, or the default value if the parameter was not specified in the invocation).The weakness of that approach became clear very quickly. For a long time the core had problems with tiddler titles that ended in double quotes because of situations like this: