Comments (4)
I've not been 100% sure when to use a pointer and when not. And, as far as I remember, Go manages structs as pointers anyway; and by this—perhaps flawed—understanding returning a pointer to struct would indeed be using a double-pointer, and indirect reference (**T
in C).
Usage of pointers as wanted by func (t *Version) f()…
would be kinda flattened by the compiler anyway. This in mind I failed to see any benefits to func (t T) f()…
and went with the former.
from semver.
Sure! Same goes for whenever you see opportunities to improve the interface.
from semver.
Actually, nevermind -- it creates allocations in the benchmarks which are currently 0, and slows it down by about 20ns. I'll just handle the referencing when needed. Thanks!
from semver.
Turns out I've been wrong: The compiler won't flatten any pointers or optimize this in any way. (With the exception of &T
for a f(… *T)
, and arrays.)
That's the why for version 3: value receivers where possible. If you (or someone else reading this) doesn't like it, keep importing version 2 and do reach out. I'll consider any back-porting if v2 is not too old by then. It's not that there are any other big functional changes between the two.
I've not made up my mind about whether to refactor any []*Version
to []Version
—which would then be grounds for releasing a version 4—for I need to learn the best solution for sorting and map-reduce. In any case, the pointer receiver to NextVersion
can and will be replaced come the next minor revision in v3 (I don't see why anyone would call NextVersion∙NextVersion
).
from semver.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from semver.