Optional semicolons are fishy

4 views
Skip to first unread message

James Aguilar

unread,
Nov 11, 2009, 3:21:25 AM11/11/09
to golang-nuts
Hey guys,

I'm sure you've discussed this to death before the public release of
the project, but I just want to jump in to say I think optional
semicolons on statements inside functions are fishy. Effective Go says
that semicolons are often left off one-liners, but one-liners often
become two-liners as programs are built over time. I suppose that our
editors will show us the error through indentation, but it seems
simpler just to require them on all statements inside functions and be
done with it.

I suspect that this feature will become one of those things that is
constantly tripping up newbies like optional braces in C. If this
feature is kept, there should probably be a specific diagnostic for it
rather than

foo.go:21: syntax error near s

which is what we get today when the compiler encounters

s += " "
s += " ";

It's going to be hard for anyone new to the language to spot problems
like this, since in most other languages adding an independent
statement to an ordinary block does not require changing other lines
in that block.

-- James

Ian Lance Taylor

unread,
Nov 11, 2009, 8:24:03 PM11/11/09
to James Aguilar, golang-nuts
James Aguilar <aguila...@gmail.com> writes:


I agree that a better error message would help in this situation.
Would you mind filing an issue for that? Thanks.

Ian

Peter Bourgon

unread,
Nov 12, 2009, 3:27:27 AM11/12/09
to Ian Lance Taylor, golang-nuts
I filed issue 89 for this. Apologies to James for cribbing his phrasing :)
http://code.google.com/p/go/issues/detail?id=89
Reply all
Reply to author
Forward
0 new messages