[REBOL] REBOL] Re: source code layout question
From: sunandadh:aol at: 4-Jan-2002 15:09
Hi Joel,
> I'm interested in any other comments on the objective pros/cons
> of these styles.
I tend to write code in your "Style C" with two minor mods:
1. I Function headers much closer to "R-polite"
2. I tend to use comments on closing brackets, especially if they are
well-separated from their opener:
] ; if
] ; func
It makes block indentation more obvious to me, and that is the clincher for
me.
But I usually "translate" code to style B before posting to the list so that
readers can cut'n'paste into the Console.
I guess what we need is not a holy war over formatting styles but
prettyprinter.r that will take arbitrary code and reformat it in various
ways. Mold sort of does that (to Style B only) but loses the comments.
I also guess a preferred formating style depends largely on what the expected
lifecycle of the code is. I assume code is a high maintenance item, and leave
it spaced out to make modifications (in my option) easier. As an example, I
was never convinced by Carl S's "mental reduction" example in Zine/2. He
reduces a Style B snippet:
either (mode) [
data: find data "Active"
][
data: find data "Passive"
]
to the one-liner:
data: find data either mode ["Active"]["Passive"]
Now that may be absolutely necessary in some circumstances where memory is
tight. But my instinctive reaction was: "Arrghh no! What if I then need to
perform an additional according to the value of 'mode?" The original is much
clearer as to where that additional code should go.
Sunanda.