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

[REBOL] Re: source code layout question

From: carl:cybercraft at: 5-Jan-2002 12:41

On 05-Jan-02, Joel Neely wrote:
> foo: func > [ "Computes a Euclid string for numeric data" > x [integer!] "major argument" > y [integer!] "corporal argument" > z [integer!] "seed string, modified by evaluation" > ][ either x = 0 > [ z] > [ either y = 0 > [ head reverse z] > [ while [x < y] > [ y: y - x > append z "x" > ] > foo y x z > ] ] ]
I rather like that, in that the relationship between the opening and closing brackets is much easier to see than with conventional styles, it creating obvious vertical lines. It's only drawbacks I think are three extra spaces on some lines (minor) and not being able to cut and paste it into the Console - a major disadvantage, I think. If it wasn't for that, it'd be tempting to switch to it. And when there's no nesting, the code becomes very clear... if x = 0 [ y] either a = b [ c] [ d] while [h = i] [ j k l] for n 1 10 1 [ print n] quit My current style (such as it is:) is much the sames as Petr's, ('either's blocks being on one line being fine with me, though I see your point in only allowing it with 'while's conditional block), so I'd write... foo: func [ "Computes a Euclid string for numeric data" x [integer!] "major argument" y [integer!] "corporal argument" z [integer!] "seed string, modified by evaluation" ][ either x = 0 [z][ either y = 0 [head reverse z][ while [x < y][ y: y - x append z "x" ] foo y x z ] ] ] And that's a line longer than your somewhat more clearer version. I try not to have more than one evaluation on a line though, unless they're within a block. So this I'd try to avoid - (usually:)... while [x < y][y: y - x append z "x"] Even though it'd save three lines. Pity about the cutting and pasting problem Joel. ): -- Carl Read