Giter Club home page Giter Club logo

Comments (2)

louthy avatar louthy commented on May 18, 2024

First change: The overrides which call CheckInitialized ...

Yep, some silly mistakes there. I've taken a different approach to fixing it:

        public T Value => 
            CheckInitialised(value);

        public static implicit operator T(Some<T> value) => 
            value.Value;

        public override string ToString() =>
            Value.ToString();

        public override int GetHashCode() =>
            Value.GetHashCode();

        public override bool Equals(object obj) =>
            Value.Equals(obj);

It puts slightly more burden on the Value access, but I think overall it's cleaner.

For performance reasons, the CLR will not call the default constructor on struct arrays.

It's not the CLR, it's the C# compiler. It could easily call the same series of op-codes that it does for classes. It is however (like you say) an optimisation. I believe the C# team are discussing default constructors for the final C# 6. So we'll see how that goes. Until then Some<T> will always be a weak solution to this problem.

I do discuss this on the project home page, and explain its limitations. I think only using Some<T> for method arguments, and never instantiating them manually is probably the best use of a weak solution.

Thanks for the heads up on the bugs!

from language-ext.

tejacques avatar tejacques commented on May 18, 2024

No problem -- I like the way you handled everything, I think that makes it work out nicely. Closing this issue now.

from language-ext.

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.