Would it make sense to mark the methods requiring pointer receiver types on the 
interface definition, instead of on the function type parameters? It seems more 
logical given that this should be a general property of the semantics of the 
interface method in question, and not something each function should have to 
deal with separately.

>From the example in the draft proposal:

// Setter is a type constraint that requires that the type
// implement a Set method that sets the value from a string.
// Further, the Set method must take a pointer receiver.
type Setter interface {
    *Set(string)
}

The * marks this method as requiring a pointer receiver.  This constraint can 
thus be enforced generically for any type up front at constraint-checking time.

A function using this interface constraint would just have a regular 
non-pointer type:

func FromStrings(type T Setter)(s []string) []T { ... }

- Randy

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3AE909EC-AA38-4ECF-8F25-FE34D898C6FD%40gmail.com.

Reply via email to