In the "Pointer vs. value methods in contracts" section, it says "that it 
will prevent writing a function body that requires a value method". 

But, the go spec states:

     That function may be called normally with an explicit receiver, so
     these five invocations are equivalent:

     t.Mv(7)
     T.Mv(t, 7)
     (T).Mv(t, 7)
     f1 := T.Mv; f1(t, 7)
     f2 := (T).Mv; f2(t, 7)

Which lead me to the following for forcing a

a) value method

contract stringer(x T) {
        var _ string = T.String(x)
}

b) pointer method

contract stringerp(x T) {
        var _ string = (*T).String(&x)
}


c) field with function type

contract stringerField(x T) {
        unsafe.Offsetof(x.String)
        var _ string = x.String()
}

Am I interpreting something wrong, or can these be used in cases where you 
care about value/pointer methods and field functions?

Thanks,
Todd

-- 
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