On Thursday, March 8, 2018 at 12:36:19 PM UTC-5, Ian Lance Taylor wrote:
>
> On Thu, Mar 8, 2018 at 9:13 AM,  <di...@veryhaha.com <javascript:>> 
> wrote: 
> > 
> > On Thursday, March 8, 2018 at 11:49:18 AM UTC-5, Ian Lance Taylor wrote: 
> >> 
> >> On Thu, Mar 8, 2018 at 8:43 AM,  <di...@veryhaha.com> wrote: 
> >> > 
> >> > There are two semicolon rules in Go spec: 
> >> > https://golang.org/ref/spec#Semicolons 
> >> > The first one states how a semicolon will be automatically inserted, 
> >> > however, the second one states how a semicolon can be omitted. 
> >> > Isn't more consistent to modify the second one to the following 
> >> > description? 
> >> > 
> >> > To allow complex statements to occupy a single line, a semicolon may 
> be 
> >> > inserted before a closing ")" or "}". 
> >> 
> >> We would have to change a lot of the syntax productions.  For example 
> >> 
> >> StructType    = "struct" "{" { FieldDecl ";" } "}" . 
> >> 
> >> The rule as stated permits omitting the final ";" when the "}" follows 
> >> on the same line (if the "}" is on a different line, the ";" is 
> >> inserted automatically anyhow).  If we change to your version, we need 
> >> to rewrite the StructType production to not have a trailing ";", and 
> >> then rely on the new rule to permit adding one. 
> >> 
> > 
> > Ok, get it. 
> > 
> > But how about just change the second rule to the following instead. 
> > 
> > To allow complex statements to occupy a single line, a semicolon may be 
> > optional before a closing ")" or "}". 
> > Compilers will insert it back if it is absent. 
>
> I guess I'm not sure why that is any clearer than the current rule. 
>
The benefit of the new one is it is easier to explain the rules for new 
gophers.
With the modified version, we can explain the rules as:

Many semicolons in Go are optional, compilers will insert back the absent 
semicolons for us automatically.
The insertion rules are 1) ..... 2) .....
 



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

Reply via email to