4 ms·
make(* Point) seems much better than having a separate new keyword. Surprised to hear that was changed after just a few days.
by grannyg00se 13y ago
make(* Point) seems much better than having a separate new keyword. Surprised to hear that was changed after just a few days.
- oofabz 13y agoThe "new" keyword is practically unused in modern Go development, but is kept for backwards compatibility. The usual way to make a point is "p := &Point{}", without using any keyword.
- rsc 13y agoNot true. I count "new" being used about half as often as "&Point{}" in the Go standard library. That's not "practically unused". g% cg -c -f 'g/go/src/pkg.*\.go' '\bnew\(' | total 2 1485 g% cg -c -f 'g/go/src/pkg.*\.go' '\&[A-Za-z0-9_.]+\{' | total 2 3051 g% cg -c -f 'g/go/src/pkg.*\.go' . | total 2 430482 g% So 430,482 non-blank lines of code, 1485 lines with new, 3051 lines that look like a struct pointer literal.
- deleted 13y ago[deleted]
- trentmb 13y agoIf I had to guess, I think they meant that anyone writing new code will avoid using 'new'.