Re: gtk2-perl: moving on by standardizing our code



On Thu, 2003-03-13 at 17:24, Christian Borup wrote:
On ons, 2003-03-12 at 20:40, Guillaume Cottenceau wrote:
       C code
1: opening curly of a function after a newline

This seems inconsistent to me and less readable. I prefer { on the same
line. I see no difference from control structures.

C functions cannot nest, whereas C control structures can.  the
difference in brace style is therefore not so inconsistent.  java and
perl can nest functions, so open { of a function on the same line makes
sense for those languages.

c.f. linux kernel coding style, <kernelsrc>/Documentation/CodingStyle:
"Heretic people all over the world have claimed that this inconsistency
is ...  well ...  inconsistent, but all right-thinking people know that
(a) K&R are _right_ and (b) K&R are right.  Besides, functions are
special anyway (you can't nest them in C)."




2. for one-lines, do we use `shift' or do we name the parameters
   using $_[0], $_[1], etc? I don't have an opinion here. Using
   `shift' can be better because then you can use @_ for the
   parameters of the functions, with any number of parameters.

I think $_[0]->foo is clearer than shift->foo...
But again I won't make a fuss about it.

i would say, if it honestly saves space and is not ambiguous, e.g., 

  sub redirected_method { shift->other_method_with_same_args (@_) }

then that's great.  otherwise, it can get really confusing, and the
$_[index] notation is much more explicit.   ...and we're back to "it
depends".


i think the important this is for us to write *maintainable* perl, which
is very different from "highly creative and ingenious" perl.  the latter
sometimes saves space and processing, but more often creates headaches
for maintainers of the resulting line noise; even the author can have a
hard time figuring it out after a month or two.



-- 
muppet <scott asofyet org>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]