One document about Go

bearophile bearophileHUGS at lycos.com
Tue Jun 1 11:03:59 PDT 2010


I have just found it through Reddit, "Some Trucs and Machins about Google Go", by Narbel:
http://dept-info.labri.fr/~narbel/Lect/go-lecture.pdf

Few comments about the text.

----------------

In Go you can omit semicolons at the end of lines, so I presume it's not a terrible thing for C-like languages:

package main
import " fmt " // formatted I/O.
func main() {
    fmt.Printf ("Hello Hello\n")
}

----------------

In Go you can omit some () for example in "if":

if !*omitNewline {
    s += Newline
}


Generally I don't like to remove the parentheses of function calls (as done in Ruby), but in this case of the 'if' syntax I think removing them helps remove some useless visual noise from the code.

----------------

The multiple return values is the Go feature I'd like most for D3 (beside named arguments):


func f(int i) (int, string) {
    return (i+1) ("supergenial")
}
x, y := f(3);

----------------

Page 15-26 shows that there is polymorphism in Go too. Go designers are trying to invent/adopt something simpler than C++-style templates.

----------------

Bye,
bearophile


More information about the Digitalmars-d mailing list