Fallthrough must be a design choice but goto's restriction is a necessity. 

What happens if you jump into the middle of an if block? You skipped the 
condition check, you run the code after the goto label, what about the code 
before the label, there might be some variables initialized, and how will 
you use this variables if you skip the initialization code.

Same applies to loops, furthermore, which iteration are you gonna be in?

On Saturday, August 5, 2017 at 12:48:40 AM UTC+2, T L wrote:
>
>
>
> On Tuesday, August 1, 2017 at 8:41:21 AM UTC-4, Jan Mercl wrote:
>>
>> On Tue, Aug 1, 2017 at 2:34 PM Fumi Takeuchi <fmodqu...@gmail.com> wrote:
>>
>> > Example code: https://play.golang.org/p/dVtPVt3oKt
>> >
>> > Maybe `fallthrough` statement cannot be used in `if` block even if it's 
>> put inside `swicth` block)
>>
>> True: It may be used only as the final non-empty statement in such a 
>> clause <https://golang.org/ref/spec#Fallthrough_statements>.
>>
>
> why to make this restriction?
>
> And why to make the similar restriction for goto:
>
> https://golang.org/ref/spec#Goto_statements
> "A "goto" statement outside a block cannot jump to a label inside that 
> block"
>
>  
>
>>
>> > 3. Other (please comment)
>>
>> https://play.golang.org/p/8rL0zqaLP3
>>
>> -- 
>>
>> -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.

Reply via email to