Tiddler Transclusion and Inheritance

230 views
Skip to first unread message

Mohammad

unread,
Dec 6, 2019, 4:54:09 AM12/6/19
to tiddl...@googlegroups.com
Alan Aldrich in his plugin TiddlyTables used transclusion to make sophisticated stylesheet and this shows the beauty of TW.
TiddlyTables has a lot to be learned as a modern application of Tiddlywiki. Hope developer, admins and TW decision makers pay more attention to this
great piece of work.

My question
Is there any example to create tiddlers with inheritance?

Example to clarify the question

  • Assume you have Tiddler 1 entitled parent
    • parent has some fields like first-name, last-name, age
    • parent text uses fields first-name, last-name, age in text (tiddler body) through transclusion
  • Now we create Tiddler 2 entitled child1
    • The body (text) of child1 is {{||parent}}
    • child1 has only two fields first-name, and age
    • one expects child1 inherits last-name
  • You may have several children each similar to child1
    • If a field is NOT existed then it will be inherited in text from parent
    • If a field is existed then its child will use its own field value
This may bring some idea about object oriented programming!
I am looking for some new idea! A similar working case (not what I described above) can be found in Alan Aldrich for making table stylesheets. 

--Mohammad 

TonyM

unread,
Dec 6, 2019, 6:35:54 AM12/6/19
to TiddlyWiki
Mohammad

Such a suggestion is already possible and I have done similar things. However I usually reserve the text field for notes and deliver the transclusions etc via the view template.

I am not exadurating saying almost anything is possible in tiddlywiki, that is why it is my obsession.

Tony

PMario

unread,
Dec 6, 2019, 6:39:50 AM12/6/19
to tiddl...@googlegroups.com
Hi Mohamad,

I think your example doesn't work, since the "inheritence" in this case won't hold. The "child" always needs its own last-name.

eg: Let's say parent-1 and parent-2 have different last-names. The child will be transcluded into both parents and would therefore have 3 different last-names.

In reality a child can get:

 1) child gets parent-1 last-name
 2) child gets parent-2 last- name
 3) a combination of parent-1 and parent-2 last-name
and may be
 4) If child is old enough it can decide to get a completely different name.

------------------

I think inheritance violates the tiddlers number 1 rule: A tiddler is the smallest unit of content, that makes sense on its own.

have fun!
mario

PMario

unread,
Dec 6, 2019, 6:41:03 AM12/6/19
to TiddlyWiki
On Friday, December 6, 2019 at 12:39:50 PM UTC+1, PMario wrote:
eg: Let's say parent-1 and parent-2 have different last-names. The child will be transcluded into both parents and would therefore have 3 different last-names.

Text edited in first post.
-m

TiddlyTweeter

unread,
Dec 6, 2019, 7:11:20 AM12/6/19
to TiddlyWiki
Ciao PMario & Mohammad

TBH, I think it would be well worth having some concrete, fairly detailed, examples of this & different strategies. 
While the official docs are good, the more formal compact presentation doesn't always illustrate well.

I'm very interested in tools and methods for complex transclusion. 
In particular, for examples that allow the writer to stay "in flow", rather than segway.

I'm less bothered if its "philosophically right" than if it helps me write articles (assemblages of Tiddlers) efficiently.

Best wishes
TT

Mark S.

unread,
Dec 6, 2019, 10:03:38 AM12/6/19
to TiddlyWiki
You've kind of skipped to an advanced computer science topic -- two parent inheritance.

C++ offers two-parent inheritance, but most modern systems, like Java don't. It's just too messy and complicated.

In biological inheritance, nature tosses a coin and various features are selected from each parent randomly. Probably not what one wants in their TW app.

I think we probably want to stick with amoeba style inheritance, and assume only one parent at a time.

TiddlyTweeter

unread,
Dec 6, 2019, 10:14:38 AM12/6/19
to TiddlyWiki
Mark S. wrote:
I think we probably want to stick with amoeba style inheritance, and assume only one parent at a time.

I am not an amoeba, I am a human being.  https://www.youtube.com/watch?v=Ud-eiDxeJj4

Inheritance from two parents--apart from being biologically sound--I found very difficult to get to in TW. Not there yet. 
Things like kinship charts are difficult without it.  

TT

Mark S.

unread,
Dec 6, 2019, 11:07:44 AM12/6/19
to TiddlyWiki
Modeling kinship would not necessarily depend on the underlying software having features of multi-parent inheritance. You can have parent and child tiddlers, but their relationship would not be expressed via transclusion but via some other mechanism such as role fields, tags, etc.

Mohammad

unread,
Dec 6, 2019, 11:13:54 AM12/6/19
to tiddl...@googlegroups.com
Thank you all for your reply!

  1. At first we need simple inheritance like making different styles for a div or table elements all inherited some features
  2. There is one parent, grand parent and grand grand parent
  3. We need to have children inherit properties from their parent BUT
  4. can overload (override) some features they have themselves
Using small code I could implement one step inheritance, but one would like to have such feature from transclusion like {{!!template}}


A Demo
This demo implement one step inheritance e.g child has only one parent and no grand parent

Here in examples we have a parent with three fields: first-name, last-name, age
If a tiddler has not a field or a field with empty value, one expects child inherits its property (field/value) from parent
  • parent, child1, child2 is an example of what Mario explained and this is the current mechanism in Tiddlywiki e.g. what is called templating
  • parent, child1-p2, child2-p2 is an example of what I said in the question, simple inheritance
    • All child may not have all fields parent has or may have an empty field
    • A child if has not set a field (here a property) it will inherit that filed / value from its parent
    • NOTE: In this example child2-p2 has NO last-name field and its value has inherited from parent.
This is the content of parent2 which uses a little code to implement the above simple inheritance
I have gone through what Mark proposed ONE parent ...


What do you think?

This if work can have many use cases!

--Mohammad




Mohammad

unread,
Dec 6, 2019, 11:18:38 AM12/6/19
to TiddlyWiki
Post edited! See the original!

TonyM

unread,
Dec 6, 2019, 4:03:57 PM12/6/19
to TiddlyWiki
Parents beget children

If you create children from a parent or parents you can ensure they inherit. Starting with their parents names. If you wish a child could have a field containg not a value but a treansluded text reference. Its value will thus be inherited. Replacing this reference with a value breaks inheritance.

Genealogical trees are already possible, the designer just needs to add logic, Bimlases kin operator is powerful support for this as is Mario's tocp.

One of the keys to such structures is to ensure you also know how to handle missing values.

I know that most of the longest contributors to tiddlywiki also write plugins or propose core changes however I am avoiding this and developing my expertise in the tiddlywiki wikitext and macros rhelm I am confident I can build almost any structure and relationship.

I know I am not always taken seriously or I am criticised for my suggestions of what I perceive to be necessary but would urge you all to consider my somewhat unique perspective, an experienced IT DESIGNER who is mostly not reverting to JavaScript code.

Please consider me a resource for solving problems in the wiki text and macros space and identifying limitations therein because that is my playground. Every time I see a possible limitation I find a workaround, I have 100s of design hacks in my library for systems I want to build in the future. I figure unless I spell this out how would you know?

I already have solutions for some of the limitations I have identified and many will be published in time.

diverse communities are strong communities, embrace diversity.

Tony

Mark S.

unread,
Dec 6, 2019, 4:38:36 PM12/6/19
to TiddlyWiki
Doing this where {{!!field}} returns the inherited value would probably require a rewrite of the parser.

But you could do something like this with macros.

Each tiddler would have a field, say lparent (for logical parent).

You would invoke like <<inherited myfield>>

The macro would look to see if there was a field, "myfield". If so, it would return the value. If not, it would use lparent to check the next parent. If that didn't work it would check that tiddler's lparent field. And so on. Probably using some recursive code.

You could also possibly deal with two parents, if you're willing to designate "dominate" parents whose value wins in the case of a tie. But that's a digression.

TonyM

unread,
Dec 6, 2019, 5:47:00 PM12/6/19
to TiddlyWiki
Mark

Some thoughts

With two parents in genealogy it is recognised there is a patralinial and matralinial tree and when exploring relationships one chooses which tree to follow with, towards ancestors or descendants. In either case or when wanting to investigate both trees it is wise to limit how deep you go. Perhaps 3 back 3 forward and then allow selection of any member in the tree and regenerate 3 back and 3 forward for the selected member.

in active directory, file systems and edirectory inheritance is a litte different, its part of what I alluded to before dealing with missing values. Basicaly you look for a value locally then walk back up the tree until you find the value you are after. This allows the minimum data to be provided because it effectively trickles down unless overridden.

I have built a method to produce what I call a branch, Basicaly you iterate the whole tree but store a strait line of ancestors for each item in the tree e.g. grand, father, son, grandson in a patralinial branch.

You can then use the branch to search for an inherited attribute/value.

If you did this for both matralinial and patralinial branches you could get conflicting results and this needs to be resolved. Evolution effectively does this randomly with exceptions. When this is resolved the result needs to be stored so that subsequent decendants inherit the result.

All this can already be done with a little work.

There is one exception to inheritance flowing down the tree that my father likes to remind me.

"madness is inheritable, you can catch it from your children"

Regards
Tony

Mohammad

unread,
Dec 6, 2019, 11:09:05 PM12/6/19
to TiddlyWiki
Thanks Mark,
 I think one parent is simpler to understand and follow and more usable in Tiddlywiki than two parents!
As you said the parser needs to support inheritance if not I have to go with macros!

@TonyM
I will have a look at kin plugin by bimlas! At the announce time I found it rather complex, but now I will go deep to see 
what mechanism he is used!

--Mohammad

TonyM

unread,
Dec 6, 2019, 11:47:39 PM12/6/19
to TiddlyWiki
Mohammad,

I understands its complexity comes from its power, test it against a copy of tiddlywiki.com and using items in the toc, 

The Kin operator is like a toc only it returns the list of descendants and or ancestors as a list from a filter.

Where it gets powerful is you can exclude one kin set from another so all descendants of my grandfather except all descendants of mt father will list uncles and cousins but not my father and me and my siblings.

Regards
Tony

TiddlyTweeter

unread,
Dec 7, 2019, 8:53:33 AM12/7/19
to TiddlyWiki
TonyM wrote:

With two parents in genealogy it is recognised there is a patralinial and matralinial tree and when exploring relationships one chooses which tree to follow with, towards ancestors or descendants.


I get where you are coming from. I just thought it worth re-iterating what I have written on this before. 

Actual Western kinship systems are dominantly bilateral (descent includes mother & father; with a complication being married names which tend to be mainly patrilineal). Of course it is more complex than that (deaths of parents, remarriage, retain maiden name, sorority, adoption, step-children, same sex marriage etc.) 

The point is you need bilateral structure to even begin to depict it at all adequately
Once you have that structure the complications can be addressed.

In anthropology the "categorical kinship system" has to be bilateral because it is a "meta-level" system showing how cultures differently depict and understand kinship (which is a system of "categories for relatives" based, ultimately [in one way or another], on biology). Lineages & clans are social models that are sub-sets of that.

And there is one big issue, apart from figuring out how to enter data correctly to cross-connect children & parents: the limits of HTML lists. 
They cannot branch from conjunction ("marriage"). They do okayish with unilineal descent (patri or matri) but bilateral is, as far as I can see, impossible in HTML lists. 
So another way to display is needed in the HTML output. 

I'm aware that the focus in this thread is not necessarily on human kinship. 
But I do think that the problems depicting, especially bilateral, descent is a concrete common case worth attention.

BTW, unilineal descent has been depicted pretty successfully already in TW several times. Bimlas does it extremely well. Mat also did it in a simple way using CSS + lists.
(I can maybe find the posts if there is interest.)

Best wishes
TT

TonyM

unread,
Dec 7, 2019, 8:32:21 PM12/7/19
to TiddlyWiki
TT

Thanks for reitterating. Appreciate your knowledge here.

There is the concept of inheritance for trickle down attribute values and security which is fortunately simpler in many respects. For all types of inheritance its worth collecting tools an methods for designers. What ever the way html list work its a fact any relationship can be represented in tiddlywiki.

I challenge anyone to describe a relationship the don't thing tiddly wiki can represent if not present diagramaticaly.

Regards
Tony

Reply all
Reply to author
Forward
0 new messages