Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion go fmt and multi-line conditionals
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Kyle Lemons  
View profile  
 More options May 24 2012, 6:07 pm
From: Kyle Lemons <kev...@google.com>
Date: Thu, 24 May 2012 15:07:45 -0700
Local: Thurs, May 24 2012 6:07 pm
Subject: Re: [go-nuts] Re: go fmt and multi-line conditionals

On Thu, May 24, 2012 at 2:14 PM, Kevin Ballard <kball...@gmail.com> wrote:
> Yes, that's what I'm suggesting. It keeps the conditional visually grouped.

Please no.  I see that for function argument indentation for some
languages, and it often ends up with about 10 characters of leeway *on
every subseqent line*.
> -Kevin

> On Thursday, May 24, 2012 at 1:09 PM, Paul Borman wrote:

> So with something like:

> <TAB>if value, err := something.Method(buffer, source); err == nil &&
> value == 17 {
> <TAB><TAB>code
> <TAB>}

> you would end up with

> <TAB>if value, err := something.Method(buffer, source); err == nil &&
> <TAB>                                                   value == 17 {
> <TAB><TAB>code
> <TAB>}

> ?

> On Thu, May 24, 2012 at 1:00 PM, Kevin Ballard <kball...@gmail.com> wrote:

> On Thursday, May 24, 2012 at 8:32 AM, Paul Borman wrote:

> Do forget other cases:

> } else if A && B ... {

> if statement; A && B ... {
> }

> And so on.  There coud be an entire heuristics paper on how best to format
> these things.  I agree the current gofmt solution is not optimal, however,
> having a single sub-optimal solution beats multiple "optimal" solutions.
>  With gofmt I know what to expect when reading code.   (And even BSD vs GNU
> go code would look the same with gofmt, oh the horrors!)

> The solution I'm proposing still fits here. Just one rule: "continued
> conditionals on subsequent lines are indented (with spaces) to match the
> start location of the conditional on the first line". This should cover all
> the cases.

> On Thursday, May 24, 2012 at 2:17 AM, Reynir Reynisson wrote:

> Some people might use a three space wide tabstop.

> Then those people can live with having their conditionals visually line up
> with the body of their scope.

> Either we use >1 tab (or tap + spaces) to indent subsequent lines, which
> looks awful for everybody, or we use a solution that looks good for nearly
> everybody but the occasional person with weird settings has a slightly
> sub-optimal experience (and honestly, their experience would just be the
> same as everybody else's is today).

> -Kevin

>     -Paul

> On Thu, May 24, 2012 at 8:23 AM, Norbert Roos <nr...@webware-experts.de>wrote:

> On 05/24/2012 11:17 AM, Reynir Reynisson wrote:

> if conditionA&&
>    conditionB&&
>    conditionC&&  {
> bodyOfStatement()
> }

> Some people might use a three space wide tabstop.

> ... which would result in

> if conditionA&&
>   conditionB&&
>   conditionC&&  {
>   bodyOfStatement()
> }

> Norbert


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.