<$vars thisYear=<<now "YYYY">>>: What do you think thisYear is?

Disregard this post. My understanding of how the vars widget behaves is based on the TiddlyWiki.com documentation, and come to find out the documentation is wrong.

The documentation misleadingly suggests that variables and macros behave the same, and they do not.

You will become a better TiddlyWiki programmer when you understand that thisYear is not 2023.

Do you understand why I say that?

Do you disagree? Why?

Really, I have no idea if that makes any sense,

Just a funny thought.

A variety of thoughts would be wildly interesting.

$vars is sooo 2015. $let is the new black. You gotta get with the times, ol’ fella :wink:

“LET” helps to identify when I’ve got some variables that depend on other variables.

“VARS” helps to identify when I’ve got some variables that do not depend on each other.

These are handy visual cues to help me with challenges to process details, and otherwise help in documenting code regardless of cognitive ability. For those who like that kind of thing.

Just trying to stay out of dysfunction.

Man, I hate it when documentation is not clear and/or inconsistent.

From https://tiddlywiki.com/#Variables and my understanding from the beginning for variables and macros:

By themselves, the snippets are not parsed as WikiText. However, a variable reference will transclude a snippet into a context where WikiText parsing may be occurring. Within a snippet, the only markup detected is $name$ for a macro parameter transclusion and $(name)$ for a variable transclusion.

But that is bunk. True for macros, but not for variables. Case in point, the following sample code:

\define thisYear2() <<now "YYYY">>

<$vars thisYear1=<<now "YYYY">>>

text widget results: <$text text=<<thisYear1>>/>, <$text text=<<thisYear2>>/>

direct reference results: <<thisYear1>> , <<thisYear2>>

</$vars>

Results in:

text widget results: 2023, <<now "YYYY">>

direct reference results: 2023 , 2023

So contrary to the documentation, variables do not behave like macros.

Hi @Charlie_Veniot I think the issue here is that the following two constructions are not equivalent:

\define thisYear2() <<now "YYYY">>

<$vars thisYear1=<<now "YYYY">>>

The first line assigns <<now "YYYY">> as a literal string to the variable thisYear2. The second line assigns the result of immediately evaluating <<now "YYYY">> as a string to the variable thisYear1.

The following line from https://tiddlywiki.com/#Macros may be confusing here:

Most macros are in fact just parameterised variables.
They are created using the \define pragma. (Behind the scenes, this is transformed into a $set, i.e. macros and variables are two sides of the same coin.)

These lines are actually equivalent:

\define thisYear() <<now "YYYY">>

<$vars thisYear="""<<now "YYYY">>>""">

Both assign the literal string, as Jeremy noted. Without the extra quotes in $var, this is not true.

I your post #5, you seem to show that thisYear (there it’s called thisYear1) does equal 2023…

Have a nice day
Yaisog

Before post 5, I believed what the documentation suggested: that variables and macros behave the same.

Post number 5 is the result of me discovering that the documentation is wrong and/or misleading on the subject.

So the OP was based on junk documentation.

Quite possibly, someone put in a lot of effort to write a good piece of documentation. I know from experience that it is not easy to formulate everything well and without mistakes. Your criticism would be more constructive if you proposed improvements instead.

I rely heavily on written documentation to understand things. Having to ask questions all of the time is a cognitive overload problem.

And I get really upset when my understanding of something is not right. That’s usually way over the top because of my cognitive disabilities.

So when the documentation I depend on leads me astray, I get besides myself upset. because I get very overwhelmed when something I thought I understood, I completely misunderstood. It turns into "everything I understood is wrong.

So that’s where I’m coming from. I know it makes no sense, but I can’t stop the brain from going there.

Communicating anything is a challenge over here.

Time for me to take another break.