Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Support instance methods. #73

Open
thargy opened this issue May 19, 2018 · 1 comment
Open

[Enhancement] Support instance methods. #73

thargy opened this issue May 19, 2018 · 1 comment

Comments

@thargy
Copy link
Contributor

thargy commented May 19, 2018

Currently, calling instance methods doesn't work. To support, we need to rewrite providing the instance as the first parameter, e.g. (extending the example in #72):

    public struct SimpleConstructedStruct
    {
        public readonly float OutFloat;

        public SimpleConstructedStruct(float outFloat)
        {
            OutFloat = outFloat;
        }

        public SimpleConstructedStruct Increment()
        {
            return new SimpleConstructedStruct (OutFloat + 1.0f);
        }
    }

...
    SimpleConstructedStruct s = new SimpleConstructedStruct(1.0f);
    s = s.SimpleConstructedStruct();

Should be written as:

    struct SimpleConstructedStruct
    {
        float OutFloat;
    };

    SimpleConstructedStruct_0_ctor(float outFloat)
    {
        SimpleConsructedStruct this;
        this.OutFloat = outFloat;
        return this;
    }

    SimpleConstructedStruct_Increment(SimpleConstructedStruct this)
    {
        return SimpleConstructedStruct_0_ctor(this.OutFloat + 1.0);
    }

...
    SimpleConstructedStruct s = SimpleConstructedStruct_0_ctor(1.0);
    s = SimpleConstructedStruct_Increment(s);
@mellinoe
Copy link
Owner

Yeah, this would be very handy. Rewriting things as static functions is both annoying and slower for regular C#.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants