Bob Hutchison | 30 Jun 21:58 2012
Picon

This is a little weird

Hi,

There's some code simple code here (http://play.golang.org/p/xvaJAtVamM) that compiles and runs. If
you remove the comma on line 21 you get a compiler error and what I find an incomprehensible error message:

prog.go:21: syntax error: unexpected semicolon or newline, expecting }
prog.go:23: non-declaration statement outside function body
prog.go:24: non-declaration statement outside function body
prog.go:25: non-declaration statement outside function body
prog.go:26: syntax error: unexpected }

Really? Is that what's meant to happen? Surely not.

Honestly, I'd have thought the extraneous comma would have been the problem not the solution.

Cheers,
Bob
Bob Hutchison | 30 Jun 22:01 2012
Picon

Re: This is a little weird


On 2012-06-30, at 3:58 PM, Bob Hutchison wrote:

> Hi,
> 
> There's some code simple code here (http://play.golang.org/p/xvaJAtVamM) that compiles and runs. If
you remove the comma on line 21 you get a compiler error and what I find an incomprehensible error message:
> 
> prog.go:21: syntax error: unexpected semicolon or newline, expecting }
> prog.go:23: non-declaration statement outside function body
> prog.go:24: non-declaration statement outside function body
> prog.go:25: non-declaration statement outside function body
> prog.go:26: syntax error: unexpected }
> 
> Really? Is that what's meant to happen? Surely not.
> 
> Honestly, I'd have thought the extraneous comma would have been the problem not the solution.

If you have lines 19 through 22 on a single line the trailing comma isn't necessary (works with it and without it)

> 
> Cheers,
> Bob

Julien Laffaye | 30 Jun 22:03 2012
Picon

Re: This is a little weird

On 6/30/2012 9:58 PM, Bob Hutchison wrote:
> Hi,
>
> There's some code simple code here (http://play.golang.org/p/xvaJAtVamM) that compiles and runs. If
you remove the comma on line 21 you get a compiler error and what I find an incomprehensible error message:
>
> prog.go:21: syntax error: unexpected semicolon or newline, expecting }
> prog.go:23: non-declaration statement outside function body
> prog.go:24: non-declaration statement outside function body
> prog.go:25: non-declaration statement outside function body
> prog.go:26: syntax error: unexpected }
>
> Really? Is that what's meant to happen? Surely not.
>
> Honestly, I'd have thought the extraneous comma would have been the problem not the solution.
>
> Cheers,
> Bob
This is because of the automatic semi-colon insertion.
http://play.golang.org/p/U8CTrjMq9n compiles, for instance.

This is also why the curly bracket must be on the same line of an if.

Patrick Mylund Nielsen | 30 Jun 22:04 2012

Re: This is a little weird

Composite literals require trailing commas before newlines because of how semi-colon insertion works: http://golang.org/ref/spec#Semicolons


When you have the comma, no semicolon is inserted, and it continues to the closing bracket.

On Sat, Jun 30, 2012 at 9:58 PM, Bob Hutchison <hutch-lists2-QkQvdf7W/+5AFePFGvp55w@public.gmane.org> wrote:
Hi,

There's some code simple code here (http://play.golang.org/p/xvaJAtVamM) that compiles and runs. If you remove the comma on line 21 you get a compiler error and what I find an incomprehensible error message:

prog.go:21: syntax error: unexpected semicolon or newline, expecting }
prog.go:23: non-declaration statement outside function body
prog.go:24: non-declaration statement outside function body
prog.go:25: non-declaration statement outside function body
prog.go:26: syntax error: unexpected }

Really? Is that what's meant to happen? Surely not.

Honestly, I'd have thought the extraneous comma would have been the problem not the solution.

Cheers,
Bob

Aram Hăvărneanu | 30 Jun 22:06 2012
Picon

Re: This is a little weird

This is a great feature because it makes it easier to move lines
around. No need to add and remove trailing commas.

--

-- 
Aram Hăvărneanu

Patrick Mylund Nielsen | 30 Jun 22:12 2012

Re: This is a little weird

Yep. I mess up trailing commas in most other languages all the time now, but I'm not sorry.

On Sat, Jun 30, 2012 at 10:06 PM, Aram Hăvărneanu <aram.h-ksLnEZEQm9k@public.gmane.org> wrote:
This is a great feature because it makes it easier to move lines
around. No need to add and remove trailing commas.

--
Aram Hăvărneanu

hutch | 30 Jun 22:22 2012
Picon

Re: This is a little weird

Okay, thanks... Maybe that is the reason, but...

What does the fourth clause of point 1 mean?

The error message still sucks.

hutch | 30 Jun 22:23 2012
Picon

Re: This is a little weird

Never mind.

hutch | 30 Jun 22:36 2012
Picon

Re: This is a little weird

So we turn commas into terminators because semicolons are separators. For 35 years I've listened to and
even participated in this separator vs. terminator debate. I think it's time to just admit Lisp got it
right 55 years ago. Sigh.

Well. Carry on!

David Klaffenbach | 30 Jun 22:14 2012

Re: This is a little weird

Or you can go fmt and get: prog.go:21:40: missing ',' before newline in composite literal

Seems clear enough.

On Saturday, June 30, 2012 2:58:23 PM UTC-5, hutch wrote:
Hi,

There's some code simple code here (http://play.golang.org/p/xvaJAtVamM) that compiles and runs. If you remove the comma on line 21 you get a compiler error and what I find an incomprehensible error message:

prog.go:21: syntax error: unexpected semicolon or newline, expecting }
prog.go:23: non-declaration statement outside function body
prog.go:24: non-declaration statement outside function body
prog.go:25: non-declaration statement outside function body
prog.go:26: syntax error: unexpected }

Really? Is that what's meant to happen? Surely not.

Honestly, I'd have thought the extraneous comma would have been the problem not the solution.

Cheers,
Bob
hutch | 30 Jun 22:25 2012
Picon

Re: This is a little weird

It *never* would have occurred to me to use go fmt to get a usable error message.

David Klaffenbach | 30 Jun 22:42 2012

Re: This is a little weird

That's interesting.  If I make a bunch of changes doing go fmt catches some of my typos (like if I slip up and use python syntax somewhere) so I've fallen into the habit of using it before building.

On Saturday, June 30, 2012 3:25:05 PM UTC-5, hutch wrote:

It *never* would have occurred to me to use go fmt to get a usable error message.
David Klaffenbach | 30 Jun 22:43 2012

Re: This is a little weird

But I agree it does seem odd or at least inconsistent that go fmt identifies an error that the compiler doesn't.

On Saturday, June 30, 2012 3:25:05 PM UTC-5, hutch wrote:

It *never* would have occurred to me to use go fmt to get a usable error message.
Patrick Mylund Nielsen | 30 Jun 22:48 2012

Re: Re: This is a little weird

As far as I can tell, it has been fixed. Compiling http://play.golang.org/p/q1GuJd-5lZ at tip gives:

./main.go:11: syntax error: need trailing comma before newline in composite literal
./main.go:13: non-declaration statement outside function body
./main.go:14: syntax error: unexpected }

On Sat, Jun 30, 2012 at 10:43 PM, David Klaffenbach <dave-8NfpthtwZQPYtjvyW6yDsg@public.gmane.org> wrote:
But I agree it does seem odd or at least inconsistent that go fmt identifies an error that the compiler doesn't.


On Saturday, June 30, 2012 3:25:05 PM UTC-5, hutch wrote:
It *never* would have occurred to me to use go fmt to get a usable error message.

David Klaffenbach | 30 Jun 23:29 2012

Re: Re: This is a little weird

I'm seeing a pattern in the postings in golang-nuts.  It goes something like this:

1)  This is weird.
2)  Yes it is.
3)  Hey, it's fixed now.

Good job go authors!

On Saturday, June 30, 2012 3:48:00 PM UTC-5, Patrick Mylund Nielsen wrote:
As far as I can tell, it has been fixed. Compiling http://play.golang.org/p/q1GuJd-5lZ at tip gives:

./main.go:11: syntax error: need trailing comma before newline in composite literal
./main.go:13: non-declaration statement outside function body
./main.go:14: syntax error: unexpected }

On Sat, Jun 30, 2012 at 10:43 PM, David Klaffenbach  wrote:
But I agree it does seem odd or at least inconsistent that go fmt identifies an error that the compiler doesn't.


On Saturday, June 30, 2012 3:25:05 PM UTC-5, hutch wrote:
It *never* would have occurred to me to use go fmt to get a usable error message.

Jesse McNelis | 1 Jul 16:57 2012
Picon

Re: Re: This is a little weird

On Sun, Jul 1, 2012 at 7:29 AM, David Klaffenbach <dave@...> wrote:
> I'm seeing a pattern in the postings in golang-nuts.  It goes something like
> this:
> 1)  This is weird.
> 2)  Yes it is.
> 3)  Hey, it's fixed now.
>
> Good job go authors!

The Go devs have time machines. As soon as you report bugs they go
back in time and fix them. This is also why 'Russ Cox' is so many
people (and thus so productive). Every time he goes back in time
another copy of him is created.

--

-- 
=====================
http://jessta.id.au

Jan Mercl | 1 Jul 21:59 2012
Picon

Re: Re: This is a little weird

Dne 1.7.2012 16:58 "Jesse McNelis" <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org> napsal(a):
>
> The Go devs have time machines. As soon as you report bugs they go
> back in time and fix them. This is also why 'Russ Cox' is so many
> people (and thus so productive). Every time he goes back in time
> another copy of him is created.

You dont't simply leak such info. Now there's a Googler going after your 10yo grandfather.

-j

Sameer Ajmani | 1 Jul 22:35 2012

Re: Re: This is a little weird

Won't work. Russ is his own grandfather.

On Jul 1, 2012 3:59 PM, "Jan Mercl" <0xjnml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Dne 1.7.2012 16:58 "Jesse McNelis" <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org> napsal(a):
>
> The Go devs have time machines. As soon as you report bugs they go
> back in time and fix them. This is also why 'Russ Cox' is so many
> people (and thus so productive). Every time he goes back in time
> another copy of him is created.

You dont't simply leak such info. Now there's a Googler going after your 10yo grandfather.

-j

Patrick Mylund Nielsen | 1 Jul 22:36 2012

Re: Re: This is a little weird

This thread just got weiiiird.

On Sun, Jul 1, 2012 at 10:35 PM, Sameer Ajmani <sameer-iFWiy5xATs8dnm+yROfE0A@public.gmane.org> wrote:

Won't work. Russ is his own grandfather.

On Jul 1, 2012 3:59 PM, "Jan Mercl" <0xjnml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Dne 1.7.2012 16:58 "Jesse McNelis" <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org> napsal(a):
>
> The Go devs have time machines. As soon as you report bugs they go
> back in time and fix them. This is also why 'Russ Cox' is so many
> people (and thus so productive). Every time he goes back in time
> another copy of him is created.

You dont't simply leak such info. Now there's a Googler going after your 10yo grandfather.

-j


Sameer Ajmani | 1 Jul 22:44 2012

Re: Re: This is a little weird

We went back in time and changed the subject of this thread accordingly.

On Jul 1, 2012 4:36 PM, "Patrick Mylund Nielsen" <patrick <at> patrickmylund.com> wrote:
This thread just got weiiiird.

On Sun, Jul 1, 2012 at 10:35 PM, Sameer Ajmani <sameer-iFWiy5xATs8dnm+yROfE0A@public.gmane.org> wrote:

Won't work. Russ is his own grandfather.

On Jul 1, 2012 3:59 PM, "Jan Mercl" <0xjnml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Dne 1.7.2012 16:58 "Jesse McNelis" <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org> napsal(a):
>
> The Go devs have time machines. As soon as you report bugs they go
> back in time and fix them. This is also why 'Russ Cox' is so many
> people (and thus so productive). Every time he goes back in time
> another copy of him is created.

You dont't simply leak such info. Now there's a Googler going after your 10yo grandfather.

-j


Patrick Mylund Nielsen | 1 Jul 23:02 2012

Re: Re: This is a little weird



On Sun, Jul 1, 2012 at 10:44 PM, Sameer Ajmani <sameer-iFWiy5xATs8dnm+yROfE0A@public.gmane.org> wrote:

We went back in time and changed the subject of this thread accordingly.

On Jul 1, 2012 4:36 PM, "Patrick Mylund Nielsen" <patrick-5OwhuJu8WGN86Ms11P7pYQC/G2K4zDHf@public.gmane.org> wrote:
This thread just got weiiiird.

On Sun, Jul 1, 2012 at 10:35 PM, Sameer Ajmani <sameer-iFWiy5xATs8dnm+yROfE0A@public.gmane.org> wrote:

Won't work. Russ is his own grandfather.

On Jul 1, 2012 3:59 PM, "Jan Mercl" <0xjnml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Dne 1.7.2012 16:58 "Jesse McNelis" <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org> napsal(a):
>
> The Go devs have time machines. As soon as you report bugs they go
> back in time and fix them. This is also why 'Russ Cox' is so many
> people (and thus so productive). Every time he goes back in time
> another copy of him is created.

You dont't simply leak such info. Now there's a Googler going after your 10yo grandfather.

-j



Matthew White | 2 Jul 02:30 2012
Picon

Re: Re: This is a little weird



On Mon, Jul 2, 2012 at 6:35 AM, Sameer Ajmani <sameer-iFWiy5xATs8dnm+yROfE0A@public.gmane.org> wrote:

Won't work. Russ is his own grandfather.

On Jul 1, 2012 3:59 PM, "Jan Mercl" <0xjnml-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

Dne 1.7.2012 16:58 "Jesse McNelis" <jessta-7L+OBQ/xVOQXC2x5gXVKYQ@public.gmane.org> napsal(a):
>
> The Go devs have time machines. As soon as you report bugs they go
> back in time and fix them. This is also why 'Russ Cox' is so many
> people (and thus so productive). Every time he goes back in time
> another copy of him is created.

You dont't simply leak such info. Now there's a Googler going after your 10yo grandfather.

-j



Gmane