Here is yet another idea for opening multiple levels on one line, that does
NOT involve column counting, only comparison of leading whitespaces.
It's a backward-compatible extension to SUBLIST (similarly applicable to
any competing FOOLIST semantics), so we could leave it undecided for now,
and legalize it later.
$ lets one open an inner list on one line, but currently it's only usable
when this list is the last element of the containing list:
outer1 outer2 $ inner1
! inner2
You cannot express (outer1 outer2 (inner1 inner2) outer3)
without giving up on use of $.
The proposal is to allow an unmatched dedent after inner2, and have that
return you to the outer level:
outer1 outer2 $ inner1
! ! inner2
! outer3
which would be equivallent to:
outer1 outer2
! inner1
! ! inner2
! outer3
More formally (described for simplicity in terms of numeric indentation
levels; easily doable in terms of exact substrings):
- Every $ pushes a "?" placeholder onto the stack of known indent levels.
- As before, increases in indentation push a specific number onto the stack.
- Dedents matching a level on the stack are handled as before, closing all
levels to the right, whether specific or placeholders.
- A dedent that doesn't match any specific level is *only* allowed if there
is at least one placeholder between the closest specific levels. All
higher levels are closed, and the *rightmost* (see rationate at end) of
these placeholders is converted to the specific level seen.
Let's say you had (10 ? ? 16) on the stack and you encounter a line
starting with 14 spaces. This closes 16 and the new stack is (10 ? 14).
A following 13 line would close 14 and leave (10 13), and then a
following 12 line would be an error.
A common objection to any scheme allowing unmatched dedents is that it
requires lookahead, both for machine parsing *and humans*. When you read:
foo
! ! bar
... pages of stuff
! ! baz
! quux
it's very disconcerting to realize that all this bar...baz stuff was not a
direct child of foo but was nested within a ...quux construct!
But in our case, $ already declares that we opened an inner construct, so I
think it won't be surprising to humans.
What about multiple $ ambiguity? Given:
A1 $ B1 $ C1
! ! C2
! B2
why does the dedent return you to the inner B level and not the outer A
level?
It's the only sane choice, for several reasons:
- Continuity with current usage, which I expect will remain the dominant
use of $: without unmatched dedents you only have access to innermost C
level, so the accessible level should be the next innermost.
- It's the only way (without magic lookahead) that allows you to access all
levels, if desired.
- It's similar to the standard resolution of "if A1 if B1 if C1 else C2
else B2".
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Readable-discuss mailing list
Readable-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/readable-discuss