FAQ
long ago, the compiler did not accept a function like

func f() ret {
for {
if blah {
return x
}
....
}

with a diagnostic that it did not end with a return statement.

Somehow, I managed to write
if cond {
return ...
}
return ...

because of that all this time.

But I just noticed that this compiler bug is still out there.

Isn't it time to let
if cond {
return ...
} else {
return ...
}

compile?

Any reason why this is not yet accepted after all this time?
It might be argued that the if accepted is one line shorter, but so is
the for construct not accepted (wrt. using a break and a return)

I'm sure it's likely I'm missing something here.

thanks

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ian Lance Taylor at Feb 4, 2013 at 7:05 pm

    On Mon, Feb 4, 2013 at 10:59 AM, Nemo wrote:
    But I just noticed that this compiler bug is still out there.

    Isn't it time to let
    if cond {
    return ...
    } else {
    return ...
    }

    compile?

    Any reason why this is not yet accepted after all this time?
    It might be argued that the if accepted is one line shorter, but so is
    the for construct not accepted (wrt. using a break and a return)

    https://code.google.com/p/go/issues/detail?id=65

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Nagle at Feb 4, 2013 at 8:48 pm

    On 2/4/2013 11:05 AM, Ian Lance Taylor wrote:
    On Mon, Feb 4, 2013 at 10:59 AM, Nemo wrote:

    But I just noticed that this compiler bug is still out there.

    Isn't it time to let
    if cond {
    return ...
    } else {
    return ...
    }

    compile?

    Any reason why this is not yet accepted after all this time?
    It might be argued that the if accepted is one line shorter, but so is
    the for construct not accepted (wrt. using a break and a return)

    https://code.google.com/p/go/issues/detail?id=65
    This also comes up with "select".

    http://play.golang.org/p/7-ghxcT4e2

    At least the compiler understands that "panic()" terminates
    the execution path. So you don't have to fake up a dummy return
    value that will never be used.

    John Nagle



    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 4, '13 at 6:59p
activeFeb 4, '13 at 8:48p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase