On 1/14/21 7:59 PM, Ian Lance Taylor wrote:
On Thu, Jan 14, 2021 at 4:33 AM Marcus Manning <icons...@gmail.com> wrote:
Hmm..., then we should appreciate the alternative to generate a hidden
instance parameter for each instantiated type in the function body. The
hidden parameters might need to be up-propagated. Further, using
reflection, these hidden parameters have to be optionals or include nil
as we don't know if instances for a type parameter are available:
The current proposal tries pretty hard to avoid requiring a specific
implementation strategy.
Ian
I don't know if this is really specific as it doesn't require that much
to a backend. Usually, this is how things work with generic
typeclasses/interfaces/traits/concepts/, you are required to provide
witness tables along with.
But because the example uses reflection, it may be more valuable just to
store reified conformances like triples as RTTI:
(type: p1.S,witness: p1.Identity[Int],interface: p2.HasIdentity[Int])
//in a global table?
Then we ask for example: reflection give me the witness for S regarding
HasIdentity //that would be idiomatic, I think.
In think, if we could add such a functionality later without to break
existing code we're fine to implement generics without this feature,
otherwise we can't introduce the proposed functionality later.
--
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/bd88f3b7-7d7f-1c94-db77-d0e87d252935%40gmail.com.