In writing the slideshow about external files and @<file> nodes, I
realize that one of the first and most fundamental Aha's in Leo's
history is mostly ignored in the docs. I'm talking about @others.
Neglecting the description of @others may be preventing people from
seeing a) how simple Leo really is and b) how thoroughly Leo
integrates outlines with programming. As prewriting for the next set
of slides, I'll explain here what makes @others special, and why it
works as it does.
The question is, how shall Leo convert an @file node to an outline?
The "natural" way would be simply to copy the nodes of the @file tree
to the external file, in outline order. But that would be horribly
inflexible. You could say that it is just plain wrong to write
outlines this way.
Instead, we can use simple markup to tell Leo how to write the
external file. As explained in the tutorial, section references work
like macro calls. They say, "put the named code here". Similarly, the
@others directive says, "put all the *other* code here".
The @others directive is an absolutely crucial invention, because it
**decouples** the format of the external file from the organization of
the outline.
Note to readers: I've never said this before, and I'm not sure how
clearly I ever realized it before. In fact, there is an essential
feature of @others that I may never have properly explained before:
**Indentation in the external files depends **only** on
the indentation of the @others directives in the outline**
Crucially, this allows the user to insert organizer nodes anywhere in
an @file tree without affecting the meaning (formatting) of the
external file.
For example, here is a template for most Python classes defined in
Leo::
class MyClass:
@others
All methods of the class are properly indented, **regardless** of
their outline position! They just have to be descendants of the top-
level MyClass node so as to be in the range of the @others directive.
Without @others, we would have no way to properly indent the nodes to
the MyClass class without tying the indentation of nodes to outline
level. That would be *way* to restrictive. Perhaps even worse, the
top-level node would look like:
class MyClass:
That's *all*. There would be no way to do put any code after the
(missing) @others. It just would not work.
The fact that Leo can represent Python programs so naturally
conclusively proves that the design of @others is spot on.
OK. It will be the task of the slideshow to explain this step-by-step
in slides. I'll probably start with section references, because
@others means "everything other than section references" :-)
Edward
P.S. Some history. No, this won't be part of the slideshow :-)
I was fortunate, you could say, that I first asked how to convert
outlines to external files when I did. In context, @others was a
completely natural invention. At the time, I was using the MORE
outliner as a prototype for Leo. I had just made the fundamental
discovery that "webs are outlines in disguise". Therefore, I knew
that I had to integrate section references with outlines. So @others
meant, everything *other than* a section reference. I don't remember
the thought process, but I invented @others within just a few minutes
of starting to use MORE as a prototype. @others has remained
unchanged ever since.
EKR
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.