Mohammad,
Yes this is useful, some tricky things can be done with this, I would
suggest documenting this in your wiki text when you use it, or you could
come undone. Such that elsewhere in your wiki when you depend on the value
from Parent.
We could call this "[re]\define"
One idea is to name the macro in a way where you know it may be overridden
eg current-a would suggest there is a value set in parent but you may
override it in the current tiddler with \define current-a.
When I write macros I try and place them in global macros and view
templates etc... rather than include them in the working tiddlers that
contain my information. In this case it can sometimes be hard to evaluate
which define is likely to win, but you can count on the current tiddler
having the known value if it contains the define.
Here is a similar example, tagged macros
\define a() {{$:/config/global-a}}
Then in a tiddler "a" returns the content of $:/config/global-a as the value
But these as you have done in your example the local tiddler can have
\define a() not-global-a <!--override global"a"-->
<<a>>
Another way is just inside a macro with set/vars etc...
\define test()
<<a>> <!-- uses global a -->
\define test-2()
<$set name=a value="local value">
<<a>> <!-- uses local a -->
</$set>
\end
Regards
Tony
On Thursday, January 23, 2020 at 5:38:00 PM UTC+11, Mohammad wrote:
>
> From: https://en.wikipedia.org/wiki/Method_overriding
>
> Assume you have a tiddler called *Parent* with the below contents
>
> \define a() This is a
> \define b() This is b
> \define main()
> <<a>>. <<b>>
> \end
>
>
> Now in *tiddler01 *do as below
>
> \import [[Parent]]
> <<main>>
>
>
> After saving it will display
> This is a. This is b
>
>
> and in *tiddler02 *do as below
>
> \import [[Parent]]
> \define a() This is NEW a
> <<main>>
>
>
> After saving it will display
>
> This is NEW a. This is b
>
>
> So, you can simply override the method a (in Tiddlywiki macro a).
>
> What do you think?
>
> --Mohammad
>
--
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/bd6f7bb3-b46d-482a-9472-5412d67743d9%40googlegroups.com.