BCPL had a construct like this, and we did consider doing something
analogous, but in the end Go is not an expression language. C and BCPL are,
and that property does lead to problems, although they are probably
avoidable with careful language design.

But Go is not an expression language, so control flow decisions are done
using control flow, and expressions don't appear in many places that they
would in other languages. Ifs and switches as expressions, while sometimes
nice to have, don't belong in Go.

-rob


On Thu, Dec 20, 2018 at 8:39 AM Tyler Compton <xavi...@gmail.com> wrote:

> There is some precedent. Python has an if expression of sorts that is
> distinct from its if statements:
>
> print(value1 if condition else value2)
>
> And in all Lisp dialects I'm familiar with, if is an expression:
>
> (print (if condition value1 value2))
>
> Not to say that this means Go should support it necessarily.
>
> On Wed, Dec 19, 2018 at 12:16 PM Jan Mercl <0xj...@gmail.com> wrote:
>
>> On Wed, Dec 19, 2018 at 9:09 PM Viktor Kojouharov <vkojouha...@gmail.com>
>> wrote:
>>
>>
>> > I'm interested to know whether it was considered (I can't imagine that
>> it wasn't) for if and switch statements to be expressions instead
>>
>> I can't imagine it was considered. Is there a precedence in other
>> language? Not even C supports that.
>>
>>
>> --
>>
>> -j
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to