Macro name collision - which version is used and where is it defined?

You can define several macros with the same name (by accident). Only one is used. I could not figure out which one is used.
From my testing it seams, that the last written (not the last changed) is used.

<<dumpvariables>> only shows the used one but it does not link to the tiddler with it’s definition.

Searching for “define macroname” gives you all definitions with the same name.

Which version is used and how to find it’s defining tiddler?

And what about procedures? From the call you don’t allways know if you have to search for \define name or \procedure name.

Firstly, I feel your pain. I’ve wanted (rarely, I admit) a <$stack-dump/> widget before. Perhaps someone with the core skills might be able to write that for us. Even so, I’m not sure the host tiddler would be available.

If you don’t mind a little HTML litter, you can add, where possible…

<span style="display:none" tiddler="$:/tiddler-name" macro="my-macro"></span>

inside your macros and then use the devtools Inspector to visually debug what’s going on.

Yes I will have to update some tools to include the new pragma etc… And the new global tags.

To answer the question which version is involved, requires working backwards from the place it is in use. In reality this may also involve values in tiddlers or fields even the result of filters. All before finding which global tag is the last to define a given macro or variable.

  • you can write your tiddlywiki script to set the variable to a particular value just before use to be more deterministic.

I dont call this a collision, I call at redefinition because it is a powerful feature. The way I manage it is in carful selection of variable names such as I know which are local and which are global. Others add prefixes or suffixes to manage names.

I also made a colapsable dumpvariables that you can filter to show a subset but rarely use it due to the above.

With definitions using a tag the last definition wins. You can use list-before and list-after including empty values to reorder or drag and drop on the tag pill.