Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Jan Mercl
On Wed, Dec 19, 2018 at 9:09 PM Viktor Kojouharov 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 12:09 PM Viktor Kojouharov
 wrote:
>
> I've tried and failed at finding any previous discussion on this topic, so do 
> point me to one if it exists.
>
> 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, and if so, 
> why were they ultimately left as statements. It seems to me that having them 
> as expressions will not cause a significant change in how they are ultimately 
> used, mostly because other languages that do support such expressions do not 
> exhibit this behaviour either. Nor is such a change strictly backwards 
> incompatible, since any expression is also technically a statement as well, 
> via the ExpressionStmt grammar rule. Such expressions also cover a simple 
> feature which a lot of people new to the language are looking for, and most 
> of us have abused in other languages - ternary operators. The Go FAQ states 
> that if-elses are clearer, if longer, which I definitely agree with. Yet it 
> seems that an if expression would retain its readability, if not outright 
> increase it, while allowing for terser assignments. The reason being that a 
> chunk of repeatable code (for example assigning to the same variable in every 
> logical branch) would be moved out of the whole block, thus highlighting the 
> value.
>
> What if the spec defines that if all if-else blocks / all switch case clauses 
> contain only single expression, they would be expressions rather than 
> statements. How would that negatively impact the language, in a way that 
> can't already be reproduced?

I think this is more or less covered by
https://golang.org/doc/faq#Does_Go_have_a_ternary_form .

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


Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Tyler Compton
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 
> 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.


Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Rob Pike
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  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 
>> 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.


Re: [go-nuts] if/switch statements as expressions

2018-12-19 Thread Jan Mercl
On Wed, Dec 19, 2018 at 9:16 PM Jan Mercl <0xj...@gmail.com> wrote:

>> On Wed, Dec 19, 2018 at 9:09 PM Viktor Kojouharov 
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.

FTR: The above about C stands. If statement is not a conditional
expression. They have different semantics and different syntax. Other
answers in this thread assume OP is actually asking about conditional
expressions.

-- 

-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.


Re: [go-nuts] if/switch statements as expressions

2018-12-20 Thread Michael Jones
There is an inelegant but highly effective "hack" in GCC/G++ in thuas area.
Since C/C++ are expression language as Rob put it (e.g. a statement like
"3" compiles where in Go it fails with "3 evaluated but not used") GCC took
this a step further and implemented that the last expression evaluated in a
block is the value of that block. This makes "x = {if (a>b) then 7 else
2;}" do what "x = (a>b)?7:2" means but allows any and all code in there.
Won't work in Go because of "3 evaluated but not used" but I've used it
gratefully in macro situations in the past.

On Wed, Dec 19, 2018 at 9:39 PM Jan Mercl <0xj...@gmail.com> wrote:

> On Wed, Dec 19, 2018 at 9: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.
>
> FTR: The above about C stands. If statement is not a conditional
> expression. They have different semantics and different syntax. Other
> answers in this thread assume OP is actually asking about conditional
> expressions.
>
> --
>
> -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.
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-20 Thread Bakul Shah
On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones  
wrote:
>
> There is an inelegant but highly effective "hack" in GCC/G++ in thuas area.
> Since C/C++ are expression language as Rob put it (e.g. a statement like
> "3" compiles where in Go it fails with "3 evaluated but not used") GCC took
> this a step further and implemented that the last expression evaluated in a
> block is the value of that block. This makes "x = {if (a>b) then 7 else
> 2;}" do what "x = (a>b)?7:2" means but allows any and all code in there.
> Won't work in Go because of "3 evaluated but not used" but I've used it
> gratefully in macro situations in the past.

Algol-68 allowed this by design. No hack required! The value
of a sequence of expressions was the last expression. It also
allowed if and switch expressions. And it allowed much more
concise alternate syntax for some constructs but with exactly
the same semantics. Among other things this meant the language
had to have union types.
  x := IF cond THEN 1 ELSE "foo" FI
or
  x := (cond | 1 | "foo")
is a perfectly legal expression. So is this:
  CASE x IN
(INT i): foo(i),
(STRING s): bar(s),
OUT error(x)
  ESAC

In my view Go could've been more of an expression language
without losing any of its strong points.

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-20 Thread Michael Jones
interesting! i wish algol 68 had had its chance.

On Thu, Dec 20, 2018 at 2:40 PM Bakul Shah  wrote:

> On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones 
> wrote:
> >
> > There is an inelegant but highly effective "hack" in GCC/G++ in thuas
> area.
> > Since C/C++ are expression language as Rob put it (e.g. a statement like
> > "3" compiles where in Go it fails with "3 evaluated but not used") GCC
> took
> > this a step further and implemented that the last expression evaluated
> in a
> > block is the value of that block. This makes "x = {if (a>b) then 7 else
> > 2;}" do what "x = (a>b)?7:2" means but allows any and all code in there.
> > Won't work in Go because of "3 evaluated but not used" but I've used it
> > gratefully in macro situations in the past.
>
> Algol-68 allowed this by design. No hack required! The value
> of a sequence of expressions was the last expression. It also
> allowed if and switch expressions. And it allowed much more
> concise alternate syntax for some constructs but with exactly
> the same semantics. Among other things this meant the language
> had to have union types.
>   x := IF cond THEN 1 ELSE "foo" FI
> or
>   x := (cond | 1 | "foo")
> is a perfectly legal expression. So is this:
>   CASE x IN
> (INT i): foo(i),
> (STRING s): bar(s),
> OUT error(x)
>   ESAC
>
> In my view Go could've been more of an expression language
> without losing any of its strong points.
>


-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-20 Thread Tom Mitchell
On Thu, Dec 20, 2018 at 2:48 PM Michael Jones 
wrote:

> interesting! i wish algol 68 had had its chance.
>

Well, "It ain't over till it is over."

http://algol68.sourceforge.net/

" multiple licenses that should be read carefully: it is open source
software, but not all components are fully free"






>
> On Thu, Dec 20, 2018 at 2:40 PM Bakul Shah  wrote:
>
>> On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones 
>> wrote:
>> >
>
> ...

>
>> Algol-68 allowed this by design. No hack required! The value
>> of a sequence of expressions was the last expression. It also
>>
>

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-21 Thread Jamie Clarkson
Happened to be randomly rereading through the EWD archives and came upon 
this simultaneously with reading this thread:

http://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/EWD230.html

(no comment!)

Jamie

On Friday, December 21, 2018 at 7:57:07 AM UTC, Tom Mitchell wrote:
>
>
> On Thu, Dec 20, 2018 at 2:48 PM Michael Jones  > wrote:
>
>> interesting! i wish algol 68 had had its chance.
>>
>
> Well, "It ain't over till it is over."
>
> http://algol68.sourceforge.net/
>
> " multiple licenses that should be read carefully: it is open source 
> software, but not all components are fully free"
>
>
>
>
>  
>
>>
>> On Thu, Dec 20, 2018 at 2:40 PM Bakul Shah > > wrote:
>>
>>> On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones >> > wrote:
>>> >
>>
>> ... 
>
>>
>>> Algol-68 allowed this by design. No hack required! The value
>>> of a sequence of expressions was the last expression. It also
>>>
>>  
>

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-21 Thread Michael Jones
It is always good to be reading Dijkstra. He was a treasure. His
observations were those of the computing world, and combined with IBM’s
dominance and desire behind PL/1, created the dead zone from which C saved
us all.

Unfortunately the good of these dead ends was lost, and the good of Algol68
was never even understood. I don’t long for them, but I miss their DNA
being in the mix.

On Fri, Dec 21, 2018 at 4:53 AM Jamie Clarkson  wrote:

> Happened to be randomly rereading through the EWD archives and came upon
> this simultaneously with reading this thread:
>
> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/EWD230.html
>
> (no comment!)
>
> Jamie
>
> On Friday, December 21, 2018 at 7:57:07 AM UTC, Tom Mitchell wrote:
>>
>>
>> On Thu, Dec 20, 2018 at 2:48 PM Michael Jones 
>> wrote:
>>
>>> interesting! i wish algol 68 had had its chance.
>>>
>>
>> Well, "It ain't over till it is over."
>>
>> http://algol68.sourceforge.net/
>>
>> " multiple licenses that should be read carefully: it is open source
>> software, but not all components are fully free"
>>
>>
>>
>>
>>
>>
>>>
>>> On Thu, Dec 20, 2018 at 2:40 PM Bakul Shah  wrote:
>>>
 On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones 
 wrote:
 >
>>>
>>> ...
>>
>>>
 Algol-68 allowed this by design. No hack required! The value
 of a sequence of expressions was the last expression. It also

>>>
>>
> --
> 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.
>
-- 

*Michael T. jonesmichael.jo...@gmail.com *

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-21 Thread Jamie Clarkson
It seems to me that what he was railing against was the design-by-committee 
approach?  Having never studied Algol68 it's hard to say but skimming the 
wiki page parts of it could be transposed directly into one about Go so I'm 
not sure the DNA is totally gone, just we're lucky to avoid the committee :)


On Friday, December 21, 2018 at 5:52:19 PM UTC, Michael Jones wrote:
>
> It is always good to be reading Dijkstra. He was a treasure. His 
> observations were those of the computing world, and combined with IBM’s 
> dominance and desire behind PL/1, created the dead zone from which C saved 
> us all. 
>
> Unfortunately the good of these dead ends was lost, and the good of 
> Algol68 was never even understood. I don’t long for them, but I miss their 
> DNA being in the mix. 
>
> On Fri, Dec 21, 2018 at 4:53 AM Jamie Clarkson  > wrote:
>
>> Happened to be randomly rereading through the EWD archives and came upon 
>> this simultaneously with reading this thread:
>>
>> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD02xx/EWD230.html
>>
>> (no comment!)
>>
>> Jamie
>>
>> On Friday, December 21, 2018 at 7:57:07 AM UTC, Tom Mitchell wrote:
>>>
>>>
>>> On Thu, Dec 20, 2018 at 2:48 PM Michael Jones  
>>> wrote:
>>>
 interesting! i wish algol 68 had had its chance.

>>>
>>> Well, "It ain't over till it is over."
>>>
>>> http://algol68.sourceforge.net/
>>>
>>> " multiple licenses that should be read carefully: it is open source 
>>> software, but not all components are fully free"
>>>
>>>
>>>
>>>
>>>  
>>>

 On Thu, Dec 20, 2018 at 2:40 PM Bakul Shah  wrote:

> On Thu, 20 Dec 2018 13:13:04 -0800 Michael Jones  
> wrote:
> >

 ... 
>>>

> Algol-68 allowed this by design. No hack required! The value
> of a sequence of expressions was the last expression. It also
>
  
>>>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
> -- 
>
> *Michael T. jonesmichae...@gmail.com *
>

-- 
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.


Re: [go-nuts] if/switch statements as expressions

2018-12-22 Thread Viktor Kojouharov
I've used kotlin extensively, where ifs and switches are expressions. I've 
also seen rust support them. Curiously, Java 12 will also support switch 
expressions, and java is about as non-expressive as it gets.

On Wednesday, December 19, 2018 at 11:39:32 PM UTC+2, Tyler Compton 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 > > 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...@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.


Re: [go-nuts] if/switch statements as expressions

2018-12-22 Thread Sameer Ajmani
Inline functions can meet this need, though there's usually a better way:
v := func() T { if b { return v1 } return v2 }()
On Sat, Dec 22, 2018 at 2:05 PM Viktor Kojouharov 
wrote:

> I've used kotlin extensively, where ifs and switches are expressions. I've
> also seen rust support them. Curiously, Java 12 will also support switch
> expressions, and java is about as non-expressive as it gets.
>
> On Wednesday, December 19, 2018 at 11:39:32 PM UTC+2, Tyler Compton 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 
>>> 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...@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.


Re: [go-nuts] if/switch statements as expressions

2018-12-22 Thread 'Axel Wagner' via golang-nuts
On Sat, Dec 22, 2018 at 8:05 PM Viktor Kojouharov 
wrote:

> Curiously, Java 12 will also support switch expressions, and java is about
> as non-expressive as it gets.
>

What makes you say that? Java is as much of an expression language as C. In
particular, assignments are expressions, which I think is pretty much
uncontested to being a mistake. So Java making making a change like that
shouldn't count as a particularly strong argument in their favor (though
I'm also not saying it should count as an argument against).


>
> On Wednesday, December 19, 2018 at 11:39:32 PM UTC+2, Tyler Compton 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 
>>> 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...@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.


Re: [go-nuts] if/switch statements as expressions

2019-01-13 Thread Sokolov Yura
Ruby has `if`, `switch` and `while` expressions.

next = if cur.val < val
 cur.right
   else
 cur.left
   end

Union type is not necessary, because there could be restriction forcing all 
branches to have same type.

-- 
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.