How to put comments in a macro definition?

I see that macros are deprecated in TW v5.3.0 but this TW is 5.2.2. I’ll wait a bit before upgrading it. So I’m using macros for now.

How do I put a comment in a macro definition? I have done a bit of searching but have not found the answer yet.

I don’t see any mention of comments in the TW docs at https://tiddlywiki.com/static/Macros.html or https://tiddlywiki.com/static/Macro%20Definitions.html

Thank you!

It follows html syntax, so you can use html’s comment format


<!-- commnet here -->

<!-- 
comment 
multi line comment 
--> 
4 Likes

Is there any efficiency impact of having an HTML comment inside the macro definition? Will the comment be removed when “calling” the macro, or will it be inserted and then ignored later when parsing HTML?
This is surely irrelevant for simple macros not called many times at once, but I’m asking for the sake of proper habits.
The alternative I see would be to put the comment after the macro definition (after \end), then it would’t be inserted when calling macro, but it’s not very handy for commenting many details at once in longer macros.

The comments have to be parsed, if they are inside the macro definition. The impact is minimal, since the parse-tree is cached.

To create the cache the comments have to be parsed only once, as long as there are no text substitutions used in the macro.

If there are text substitutions the whole macro has to be parsed over and over again. Including the comments

<!-- comment has no impact when the macro is called -->

\define my-macro()
<!-- this comment has a little performance impact when the macro is called -->
\end

<!-- comment has no impact when the macro is called -->

So for \procedure and functions definitions, comments are only parsed once inside or outside the definition. Then the caches are used, which do not contain any comment info.

2 Likes