News for hackers. Stuff that matters.
Re:Google Go: The Good, the Bad, and the Meh by DoubleCluster on Monday February 11, 2013 @11:06AM (#5201432)

  Let’s say I want to declare a pointer to a variable length
  array (what Python calls a list and Go calls a slice) of
  pointers to FooType objects:

     var foo *[]*FooType

  It reads very simply ...
What???? Not that it's better in other languages but this makes the article feel like satire. It reads like "The Ugly" and "The Bad".

Aside: What's with the completely defective comment syntax on HN? Can anyone give some hints on how to quote and how to escape the star character?

edit: formatting, thanks spacemanaki

Re:Google Go: The Good, the Bad, and the Meh by ajkjk on Monday February 11, 2013 @11:16AM (#5201481)
It's in comparison to the clockwise spiral rule: http://c-faq.com/decl/spiral.anderson.html
Re:Google Go: The Good, the Bad, and the Meh by tptacek on Monday February 11, 2013 @11:27AM (#5201551)
Which is such a baroque rule that it's probably not even a rule: http://news.ycombinator.com/item?id=5079787

Go's declaration syntax is one of the best things about the language. I thought it would take me forever to get used to, but within a day it was the opposite: C feels backwards. It's especially excellent for references to functions.

Re:Google Go: The Good, the Bad, and the Meh by DoubleCluster on Monday February 11, 2013 @11:26AM (#5201540)
Right, it may be a tiny bit better but it's still not easy to read. The only way to make it actually readable is with typedefs.
Re:Google Go: The Good, the Bad, and the Meh by niggler on Monday February 11, 2013 @11:20AM (#5201504)
Re:Google Go: The Good, the Bad, and the Meh by stevvooe on Monday February 11, 2013 @11:20AM (#5201502)
How so? There is a well thought out reason for this ordering [1], and it has taken hold in many other languages, such as rust and scala. Compare with the complexity of c or c++ type signatures.

[1] http://golang.org/doc/articles/gos_declaration_syntax.html

Re:Google Go: The Good, the Bad, and the Meh by Jabbles on Monday February 11, 2013 @11:44AM (#5201675)
I don't think there would be a simpler way of describing a type as complex as "a pointer to a slice of pointers to FooType".

Simpler variables are declared as

    var a int
or with type inference:

    var a = 10
Re:Google Go: The Good, the Bad, and the Meh by smosher on Monday February 11, 2013 @12:03PM (#5201799)
Two examples come to mind:

    [FooType]
and:

    Slice<FooType>
If you think you must, apply sigils. The position of the brackets in the Go version is atypically bad for readability.
Re:Google Go: The Good, the Bad, and the Meh by Jabbles on Monday February 11, 2013 @12:14PM (#5201861)
I don't understand.

Where do your examples say they're pointers?

How would you express this using your first syntax?

    *[4]*FooType
Re:Google Go: The Good, the Bad, and the Meh by svachalek on Monday February 11, 2013 @01:05PM (#5202168)
The first is or could be Haskell. The length of a list is not part of its type. The second looks like Java, ditto there (although built-in arrays have a different syntax).

Haskell does not have mutability at all and thus no "pointers". In Java the insides of containers are mutable so you'd have to add an outer array or list. In either case though you don't need pointers to simply pass things around as you do in C (I don't know about Go).

Re:Google Go: The Good, the Bad, and the Meh by smosher on Monday February 11, 2013 @01:35PM (#5202365)
Where do your examples say they're pointers?

They don't, it's inferred in my examples. Like I said, if you need them, you can use whatever sigils you want. They can go in front of the types as usual.

How would you express this using your first syntax?

I wouldn't. That syntax is decidedly inappropriate for vectors that incorporate length into the type.

Re:Google Go: The Good, the Bad, and the Meh by kevinnk on Monday February 11, 2013 @06:12PM (#5204039)
You could have something like * [* FooType#4]
Re:Google Go: The Good, the Bad, and the Meh by spacemanaki on Monday February 11, 2013 @11:36AM (#5201616)
Your best bet with code in comments is to indent:

  var foo *[]*FooType
http://news.ycombinator.com/formatdoc