Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Thoughts on "Go"?

by Jenda (Abbot)
on Nov 11, 2009 at 15:17 UTC ( #806515=note: print w/replies, xml ) Need Help??


in reply to Re: Thoughts on "Go"?
in thread Thoughts on "Go"?

Even if I switched to Perl6 alerady you'd not catch me skipping the parens. It just looks better with them. I don't have to put them around the condition in T-SQL either, but the only case when I don't is if the condition is a single exists (...). IMnsHO omiting the parents is just as clever as omiting the curlies in if statements in C or JavaScript. Something you can do, but sooner or even sooner it'll bite you.

Jenda
Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^3: Thoughts on "Go"?
by masak (Scribe) on Nov 11, 2009 at 15:39 UTC

    It's funny - lots of people have this reaction to the paren-lessness of Perl 6. "Yuck! I'd never leave them out!" Often with a rationale of some sort.

    A few weeks pass. The person gets comfortable with Perl 6. The scales come off; the parentheses go away.

    I've written a fair bit of Perl 6 code for 18 months now. I find the lack of parentheses easier to read and less cluttered than putting them in. After for, if, while et al., they simply don't have a purpose. They don't mean anything. The only reason other languages have them there is that they have things like braceless forms of those keywords, or that they cargo-cult C.

      The only reason other languages have them there is that they have things like braceless forms of those keywords, or that they cargo-cult C.

      Another valid reason is to prevent parsing ambiguities when the braces are optional, as in C. Making both parens and braces in an if statement optional feels like exaggerated liberty :-)

      Perl 6 - links to (nearly) everything that is Perl 6.
Re^3: Thoughts on "Go"?
by moritz (Cardinal) on Nov 11, 2009 at 15:29 UTC
    It just looks better with them

    Can't agree with that, but taste is a personal matter.

    IMnsHO omiting the parents is just as clever as omiting the curlies in if statements in C or JavaScript. Something you can do, but sooner or even sooner it'll bite you.

    I can easily see the failure mode with omitting curlies in C or JS, but I don't see what could go wrong with ommiting the parens around the if condition. Care to elaborate?

    The only thing that might become confusing is when you use a map or grep with a block without additional parens. But that's only a rather rare case, and IMansHO not good reason to include visual noise in the general case.

    (I might also add that I've written a fair bit of Perl 6 code already and haven't been bitten by that)

    Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://806515]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2017-12-11 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (310 votes). Check out past polls.

    Notices?