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
On Saturday, December 7, 2019 at 1:08:36 AM UTC+3:30, Mark S. wrote:
>
> 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.
>
>
>
> On Friday, December 6, 2019 at 8:13:54 AM UTC-8, Mohammad wrote:
>>
>> 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
>> look at : http://hirad.tiddlyspot.com/
>>
>> 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
>>
>>
>>
>>
>>
>>
>> On Friday, December 6, 2019 at 3:09:50 PM UTC+3:30, PMario wrote:
>>>
>>> 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
>>>
>>
--
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/b4f7b93a-b4e0-4c27-8b60-4be3d7b12213%40googlegroups.com.