Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: REBOL] Re: source code layout question

From: sunandadh:aol at: 5-Jan-2002 6:09

Hi Carl, Sunanda:
> > 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.
Carl:
> Well, I was convinced, and I now find the one-line version easy and > natural to read. Also, adding any additional code /is/ simple... > > data: find data either mode [a: 1 "Active"][b: 2 "Passive"]
It's easy to think up simple changes that would make the one-liner difficult to maintain: If Mode is True position Data at "Active", unless Mean is 5, in which case leave Data's position unchanged If Mode is False position data at "Passive" unless Median is unset, in which case also unset Data Or If Mode is True and Data is a series position Data at "Active"; but if Data is an integer, set it to zero. The problem is that the one-liner makes two assumptions: first that Data is a series; and second that the result of manipulating it should be a change in its position). The longer code need make neither of these assumptions. Whether those assumptions are reasonable or not is not something we can't tell from such an artificial example. But I do try to write code remembering that maintaining it is much harder than writing it. So if I've been as clever as I possibly can in distilling it down to one-liners at time of writing, my successors (including an older me) have little chance of maintaining it. Maybe what we need is not just a prettyprinter.r but also an optimiser.r. That can produce runtime code which is as densely one-lined as possible while still functionally equivalent to the original. Any takers? Sunanda.