FAQ

On Sat, Jan 26, 2013 at 10:16 PM, David DENG wrote:

Dereference is kinda cheap in many cases, may be only a change on a cpu
code.

In IntSlice<https://github.com/daviddengcn/go-villa/blob/master/intslice.go>implementation, there are so many methods of pointer receiveres:
Add/Insert/Remove/RemoveRange/Clear. Anytime the length of the slice may
change, I have to use pointer-receiver. Using an assignment statement to
make the dereference and assign the value to a variable is both ugly and
inefficiency. So my proposed shorthands can solve them very well.
It's far more common for a pointer to a slice or a string (or an interface)
to be an error by a new go dev than to be intentional. By not
automatically dereferencing the error is highlighted.

So it's slightly more annoying for rare code and highlights mistakes in
more common code.


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

--

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 6 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedJan 25, '13 at 3:45p
activeJan 26, '13 at 12:15p
posts6
users5
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase