[REBOL] Re: source code layout question
From: petr:krenzelok:trz:cz at: 4-Jan-2002 18:38
Joel Neely wrote:
>Hi, all,
>
>WARNING #1: None of the code in this post is meaningful, and may
> not even be legitimate. It's only included for
>the purpose of illustration.
>
>WARNING #2: This is a controversial and sensitive subject with
> some folks. I'm not trying to start a flame war, and
>I have not interest in debating aesthetic opinions. I *am* very
>interested in objective criteria which identify strengths and
>weaknesses of the alternatives.
>
Why do you think it could lead to flamewar? :-) It isn't
rebo-2-another-lang comparison after all :-)
>That said...
>
>I've recently been pondering source code layout. I, like many of
>us on the list, have been writing REBOL in a style similar to the
>following, which I'll call Style B:
>
> foo: func [x [integer!] y [integer!] z [integer!]] [
> either x = 0 [
> z
> ][
> either y = 0 [
> head reverse z
> ][
> while [x < y] [
> y: y - x
> append z "x"
> ]
> foo y x z
> ]
> ]
> ]
>
OK, the rest of the code is cutted-off. I think that for me, only your B
varian is acceptable, with 2 small changes
- if something can be put on one line (one-liner), don't use new line
after starting "["
- don't put starting "[" on separate line, so:
foo: func [x [integer!] y [integer!] z [integer!]][
either x = 0 [z][
either y = 0 [head reverse z][
while [x < y][
y: y - x
append z "x"
]
foo y x z
]
] ;end either x = 0 - an example of comment, good for longer
nested stuff ...
]
as for example of longer either expression, probably something like this:
either x = 0 [
head reverse z
some other stuff here
][short stuff here]
either x = 0 [
head reverse z
some other stuff here
][
another at least two
lines of code
]
>Objective comments (i.e., something other that "That's the
>ugliest thing I've ever seen!" or "Wow! You're an artist!" ;-)
>are welcome!
>
That's the ugliest thing I've ever seen and yes, you are real rebol
artist :-))
-pekr-