GithubHelp home page GithubHelp logo

Use of Pointers about semver HOT 8 CLOSED

blang avatar blang commented on May 24, 2024
Use of Pointers

from semver.

Comments (8)

blang avatar blang commented on May 24, 2024

Yep you're absolutely, a old (bad) habit of me, which never got fixed.
I will work on that the next days,

thx for pointing that out

from semver.

xogeny avatar xogeny commented on May 24, 2024

This is still a little inconsistent because in many cases the arguments are still pointers even though (again, they are not mutated).

from semver.

blang avatar blang commented on May 24, 2024

Yep, you were faster than me.
I will check if those are api breaking

from semver.

xogeny avatar xogeny commented on May 24, 2024

You might also want to double-check any benchmarks you do to make sure there isn't a performance impact. Just a thought.

from semver.

blang avatar blang commented on May 24, 2024

I'm not quite sure if changing from pointers to value arguments helps anyone.
For example:

func (v Version) Compare(o Version) int

Would no longer work if the o Version is constructed using New(..) or Parse(..)
Which could be avoided by returning values instead of pointers, since we don't often modify the version, but then we could not return nil,err in case of failure.

Any ideas?

from semver.

xogeny avatar xogeny commented on May 24, 2024

In my opinion, Parse should return a value, not a pointer and the API should generally use values. This is essentially just struct with a few values. I normally only use pointers when I want to have a receiver that gets mutated.

As for the "we could not return nil, err" comment, that isn't really an issue. If you return a value (not a pointer), just return Version{}, err. Does that answer your question?

from semver.

blang avatar blang commented on May 24, 2024

Yep i know, but i'm (still) not fully convinced of the benefits because this will break the public api.

Anyway, i've changed to values-only in the v2 branch, have a look at c8864c2
I think this looks good and benchmarks are ok.
Also have a look at the v2 branch adding sorting of version slices.
feat_v2

I will probably merge this in a couple of days.

from semver.

blang avatar blang commented on May 24, 2024

Implemented in v2

from semver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.