Skip to content

Conversation

@7sharp9
Copy link
Contributor

@7sharp9 7sharp9 commented Mar 11, 2019

As discussed in #6307
@dsyme I added a tentative implementation, Im not entirely sure this is correct, also having trouble getting this to match an Item to test.

…hSln

As discussed in #6307
@dsyme I added a tentative implementation, Im not entirely sure this is correct, also having trouble getting this to match an Item to test.
@7sharp9
Copy link
Contributor Author

7sharp9 commented Mar 12, 2019

Nope, tried lots of different things, I cant seem to trigger TraitConstraintSln.ILMethSln

@dsyme
Copy link
Contributor

dsyme commented Mar 12, 2019

Nope, tried lots of different things, I cant seem to trigger TraitConstraintSln.ILMethSln

Ah yes, of course. ImplicitOp is used for non-.NET-standard operators (e.g. <!>) and .NET types only come with standard ones.

So for now it's not really important to add that case, though I think the code you have looks correct. If you do want to add one you would have to define a .NET class with an odd operator name like op_LessThanBangLessThan and use it from F#

@7sharp9
Copy link
Contributor Author

7sharp9 commented Mar 12, 2019

@dsyme I'll keep this open and try and get a hit on this, what about the other cases:

    /// Indicates a trait is solved by an F# record field.
    | FSRecdFieldSln of TypeInst * RecdFieldRef * bool

    /// Indicates a trait is solved by an F# anonymous record field.
    | FSAnonRecdFieldSln of AnonRecdTypeInfo * TypeInst * int

What code/symbols would likely trigger those? If I can find triggers I can add them too...

@dsyme
Copy link
Contributor

dsyme commented Mar 12, 2019

@7sharp9 These won't get triggered by ImplicitOp. Remember ImplicitOp is only used for operators that are both actually operators, and do not have a corresponding let (+) x y = ... definition in scope - i.e there is literally no explicit definition of the operator.

The other cases are used for solutions to SRTP constraints. The FCS API doesn't currently show or report those solutions

@7sharp9
Copy link
Contributor Author

7sharp9 commented Mar 12, 2019

@dsyme By .Net class, do you mean something defined in C#, or just a dll reference?

@dsyme
Copy link
Contributor

dsyme commented Mar 12, 2019

@dsyme By .Net class, do you mean something defined in C#, or just a dll reference?

C#-defined (i.e. non-F# defined - you can use VB if you're brave)

@7sharp9
Copy link
Contributor Author

7sharp9 commented Mar 12, 2019

Hmm C# only has vanilla operators to overload ...

@dsyme
Copy link
Contributor

dsyme commented Mar 12, 2019

You'll need to use the name like op_ABC

@7sharp9
Copy link
Contributor Author

7sharp9 commented Mar 13, 2019

Even with something like this defined:

    public class Fraction
    {
        readonly int num;
        readonly int den;

        public Fraction(int num, int den)
        {
            this.num = num;
            this.den = den;
        }
    
        public static Fraction operator +(Fraction a, Fraction b)
        {
            return new Fraction(a.num * b.den + b.num * a.den, a.den * b.den);
        }
        
        public static Fraction op_LessThanBangLessThan(Fraction a, int b)
        {
            return new Fraction(1, b);
        }

I cant get the symbol version to be seen from F# anyway:

Screen Shot 2019-03-13 at 13 26 25

@7sharp9
Copy link
Contributor Author

7sharp9 commented Mar 13, 2019

I think I should just close this, its not like this will even exist in the wild unless VB is different

@7sharp9 7sharp9 closed this Mar 20, 2019
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

Successfully merging this pull request may close these issues.

2 participants