in reply to RE: Uncuddled else?
in thread Uncuddled else?

Note that the braces are completely unnecessary in the 'C' example, and looks quite pretty as:
if (!strcmp (invar, "true")) printf ("It's true\n"); else printf ("It's false\n");
You can make Perl just as ugly, and it wasn't very nice to yank 'C' in as a bad example. Remember, Perl is written in 'C'...

Not to mention, 'C' doesn't have a 'eq' operator, doesn't support variables with $ in the name, and only single characters may be single quoted, so it wouldn't have compiled anyway.

And sometimes, I sure wish Perl didn't require bracing the code block after 'if' or 'else', because I don't like cuddled style parans, anyway.

--Chris

e-mail jcwren

Replies are listed 'Best First'.
RE: (jcwren) RE: (2) Uncuddled else?
by cwest (Friar) on Oct 16, 2000 at 22:25 UTC
    Yes I know braces are optional when there is one statement in the block.

    Perl can be as ugly as one writes it.

    Many programmers come from 'C', find the braces mandatory and write Perl like they would write 'C' with braces. It's a fair example.

    Just because Perl is written in 'C' doesn't mean I can't think it's ugly ;-) ( note the smiley ).

    I know 'C' syntax, don't flame me over trivial matters.

    I'm not attacking 'C', I'm using it as an example. That's all. Not everyone writes 'C' like that, I don't.

    Please calm down and note the smiley!

    :c)~

    --
    Casey
       I am a superhero.
    
RE: (jcwren) RE: (2) Uncuddled else?
by AgentM (Curate) on Oct 16, 2000 at 23:19 UTC
    Hmmm. i think that's what larry might have had in mind when he let's us reverse the directives, as in:
    $do_this if $this;
    But you're right, i also miss the one-liner-skip-brackets syntax :-( Also, I agree with you- flaming C is bad with or without a smiley face.

    But I find cuddled parentheses useful when I have a long block of code, let's say in a while loop, where I don't want to search of the end of some cryptic line where the matching parenthesis is :-O. of course, if one uses a real editor, parenthesis matching is builtin as a quick back hilite but since brackets are not color-coded to matching brackets, it seems simpler to look up your code a few lines and see a matching bracket, indented the same spaces as the matching one below. That's all. But I guess it's just a stylistic issue and nothing painfully important.

    AgentM Systems or Nasca Enterprises is not responsible for the comments made by AgentM- anywhere.