On Wed, 12 Sep 2018 10:54:15 -0700
jimmy frasche <soapboxcic...@gmail.com> wrote:

> because that misses cases like
>   type Float float64

I am working on constraint examples for CGG.
[https://github.com/ohir/gonerics] (Appendix A)

With CGG `for type` contracts now you can use constraint
that allows for any custom type of base float64

`for type T = float64() // T must be assignable to given base via a cast`

so example func becomes:

func maMustFMA(a, b, c type T) type T {

   for type T = float64()

   // Here yours Float match and
   // a, b, c are treated by the code as float64
   //...

}

I assume that this is not enough for you to narrow
contract to 'FMA capable'. Or is it?

(As by the https://github.com/golang/go/issues/25819
comments, given float64 compiler should know).

Is that true? If so, what kind of constraint 
(in terms of Go type system) would fit your needs
in place of below "someConstraint".

func maMustFMA(a, b, c type T) type T {
for type (
    T = float64()
        T = someConstraint // 
)
// ...
}

Thanks in advance for the answer

-- 
Wojciech S. Czarnecki
 << ^oo^ >> OHIR-RIPE

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to