[REBOL] Transpose Re:(4)
From: joel:neely:fedex at: 6-Oct-2000 17:00
This is clearly one of those "you say tomato, I say ketchup" issues.
Anyone who doesn't like ketchup on his steak (or steak under his ketchup)
is welcome to skip this post entirely!
-jn-
[Al--Bri--xtra--co--nz] wrote:
> Rebol Crew wrote:
> > The contents of a block are indented, but the block's enclosing brackets
> [] are not. That's because the brackets belong to the prior level of syntax
> as they define the block, but are not contents of the block. Also it's
> easier to spot breaks between adjacent blocks when the brackets stand out.
>
> I disagree with Carl's reasoning here, but I can cope with it. I prefer the
> better human readable style like this example:
>
> repeat Index Width [
> Column: make block! Width
> foreach Row Matrix [
> insert/only tail Column Row/:Index
> ]
> insert/only tail Results Column
> ]
>
I've always understood INdentation as showing what was IN something else.
Viewed strictly as a block (i.e. ignoring the fact that I think I know what
some of those words mean...) the example above has this shape to my mind's
eye (abbreviating a few places -- strictly for space -- and making explicit
an enclosing block...):
[*]
/----------^---------\
repeat Index Width [*]
/-------------------------------------------^------------------------\
Column: make block! Width foreach Row Matrix [*] append Results Column
/---------^---------\
append Results Column
(Those hyphens, carets, asterisks, slashes, and backwardslashes are
standing in for the nice pretty lines in my head...)
The top level block contains 4 things -- three words and another block.
That last block contains 11 things -- the eighth of which is another
block. etc... Notice that the contents are UNDER the brackets -- [*] --
that mark the boundaries of the block.
Of course, this horizontal layout is not going to work typographically,
especially in email, as my lists get longer. So we can rotate it to run
vertically. Unfortunately I don't have rotated brackets on my keyboard,
so I'll just have to use the same old more-or-less-vertical ones:
/ repeat / Column:
[ | Index | make
*-< Width | block!
] | [ | Width
| *------< foreach
\ ] | Row
| Matrix
| [ / append
| *-------< Results
| ] \ Column
| append
| Results
\ Column
Notice that the contents of a block are still under the brackets that
mark the block's boundaries (although logical "under" is now geometrically
to the right
). Of course all these overlapping columns of words and
lines are a little cluttered (even though more compact) so let's try to
declutter by putting contents between the boundaries of their blocks
(but still INdenting to make it clear that they are INside the blocks):
[
repeat
Index
Width
[
Column:
make
block!
Width
foreach
Row
Matrix
[
append
tail
Column
Row/:Index
]
append
tail
Results
Column
]
]
Now let's remember that we know what these "words" mean. If we do,
we'll tend to think of bigger units, perhaps called "phrases", that
group words into fewer, bigger chunks. If I do that, I'll have to
keep the first word of a new phrase back at the same level that
it had before I started "chunking", so I don't lose track of my
levels.
If one of these phrases includes a block, I may try to write it out
all at once. but if it doesn't fit, I'll try to pull the open brace
into the line with the rest of the phrase, but leave the content
indented with the closing brace "outdented" back to its own level
to make it clear that I've come back up/out a level in the structure.
[
repeat Index Width [
Column: make block! Width
foreach Row Matrix [ append tail Column Row/:Index ]
append tail Results Column
]
]
This also lets me work top-down/breadth-first into the structure,
only disclosing lower levels as I work my way down to them. To
my eye, an empty (or hidden) block is ONE thing even if it's written
with two keystrokes "[]". When I have to break the case open, I
put the two halves at the same level
Level 0 view ("outside"):
[]
Level 0 opening:
[
]
Level 1 revealed:
[
repeat Index Width []
]
Level 1 opening:
[
repeat Index Width [
]
]
...
Well, no point in beating this dead horse further -- the horse steak
is as tender as its going to get!
However, notice that (in the spirit of comprimise) I've tried to keep
the initial caps on Important Words! ;-)
--
; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677
REBOL [] print to-string debase decompress #{
789C0BCE0BAB4A7176CA48CAB53448740FABF474F3720BCC
B6F4F574CFC888342AC949CE74B50500E1710C0C24000000}