One document about Go

Lurker nospam at spamfree.net
Tue Jun 1 11:50:38 PDT 2010


== Quote from bearophile (bearophileHUGS at lycos.com)'s article

> 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")
> }

When will D support that? Removing unnecessary semis really pretties up the
code.

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

I disagree.

> ----------------
> 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);

Combine the 2 things into one struct and return by value. Multi-value return
makes for hard to comprehend code. So, IMO, it's hardly syntactic sugar:
it's syntactic grafitti.

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


"Compile-time polymorhism": you were thinking "generics/templates"? When
seeing or using the term 'polymorphism' without additional modifiers, I tend
to think of "inclusion polymorphism".



More information about the Digitalmars-d mailing list