On Wednesday, October 19, 2016 at 6:28:21 PM UTC+8, Nyah Check wrote:
>
> This can still work
>
> *var int i = 0*
> *for  i < MAX {*
> *  //statements here*
> *  i++*
> *}*
>
> Cheers!
>

but I don't want to leak i in outer block, and adding a {} pair is overkill.

>
> On Wed, Oct 19, 2016 at 11:24 AM, T L <tapi...@gmail.com <javascript:>> 
> wrote:
>
>>
>>
>> On Wednesday, October 19, 2016 at 5:43:48 AM UTC+8, Ian Lance Taylor 
>> wrote:
>>
>>> On Tue, Oct 18, 2016 at 7:50 AM, T L <tapi...@gmail.com> wrote: 
>>> > 
>>> > On Tuesday, October 18, 2016 at 10:40:02 PM UTC+8, Ian Lance Taylor 
>>> wrote: 
>>> >> 
>>> >> On Tue, Oct 18, 2016 at 7:21 AM, T L <tapi...@gmail.com> wrote: 
>>> >> > 
>>> >> > alternative question, why followings are not accepted in syntax: 
>>> >> > 
>>> >> >     if var x = 5; x > 3 { 
>>> >> >         _ = x 
>>> >> >     } 
>>> >> > 
>>> >> >     for var x = range []int{0,1,2} { 
>>> >> >         _ = x 
>>> >> > 
>>> >> >     } 
>>> >> > 
>>> >> >     switch var x = "abc"; x { 
>>> >> >     default: 
>>> >> >         _ = x 
>>> >> >     } 
>>> >> > 
>>> >> >     switch var x = (interface{}(true)).(type) { 
>>> >> >     default: 
>>> >> >         _ = x 
>>> >> >     } 
>>> >> 
>>> >> That syntax adds no functionality and, at least to me, seems uglier 
>>> >> and harder to read. 
>>> >> 
>>> >> Ian 
>>> > 
>>> > 
>>> > So the reason of adding short variable declarations is just to avoid 
>>> > so-called ugliness? 
>>>
>>> I'm sorry, I don't understand what you are asking.  Your examples are 
>>> about the way that various control flow statements permit a short 
>>> variable declaration.  Obviously short variable declarations can also 
>>> be used as statements by themselves.  I don't know what you are 
>>> referring to with your question. 
>>>
>>> Ian 
>>>
>>
>> What I mean is, if we are not forced use short forms as the first 
>> expression in control flow blocks, it would be cool.
>>  
>>
>> -- 
>> 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 <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> "The heaviest penalty for declining to rule is to be ruled by someone 
> inferior to yourself." --*Plato* 
>

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