On Monday, October 8, 2018 at 5:14:58 PM UTC+2, Edward K. Ream wrote:
>
> On Monday, October 8, 2018 at 7:46:01 AM UTC-5, vitalije wrote:
>
>
> A constant need for reloading is caused by the fact that we don't use 
>> immutable data types. 
>>
>
> Can you explain further?
>
> If you have some data structure that is immutable, you can share it freely 
and be sure that it is never stale, so there is no need to reload it ever. 
When the user or some script requires data to be changed, original version 
is not changed but new one is freshly built with required changes applied. 
Application is then usually designed using declarative style to define 
paths of data flow. Whenever new version of immutable data structure is 
created as a result of some user action, that new value is propagated 
through the application and each part updates its own state taking those 
pieces of data that it is interested in, ignoring everything else. No part 
ever needs to look back and ask if the data has been changed. 

Currently, outline data in Leo is represented by the mutable data structure 
in c.rootVnode. A position can become stale when this mutable data 
structure change. For that reason it needs always to be checked if it is 
still valid, if it exists. Let's for the moment leave aside any 
difficulties in real world and suppose that we can do whatever we wish. 
Suppose we wish to have an immutable outline. If c.rootVnode was immutable, 
then any position created using c.rootVnode, would never become invalid. It 
may become useless (in the sense that it doesn't represent currently 
reachable node)  if the c.rootVnode is replaced with some other immutable 
tree. But position will have indefinitely same meaning referring to the 
node in the original tree. Any function called with this position and 
original tree will return same result regardless of whether this result is 
still valid, usable or if it is just historical value. No function would 
need to check validity of position. Because all functions would return same 
value for same input, then their return values can be easily cached and 
lots of expensive calculations could be avoided. For example calculating 
node path involves searching for at-path directives all around. If we 
calculate this value once and if we are certain that the underlying data 
can't change, then we would never need to calculate it again. Right now, 
when saving external files, this search for at-path is executed many times 
for each external file in the outline. That is also some kind of "constant 
reloading" and is caused by mutability of the underlying data structure.

Vitalije


-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to