--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2aa1c2cb-e7bc-438e-81a9-e4a2904af21cn%40googlegroups.com.
2. It seems impossible to implement a type-safe Map function. The following code:func (l List[T]) Map(f func[U any](v T) U) List[U] {
return nil
}will not compile, with the error: function type cannot have type parametersJudging by the error message this seems to be by design, but it will significantly reduce the usability of generics for any transformation method. What is the reasoning behind this limitation?
type List[T any] []T1. The current go2go implementation does not allow one to do this:func ToList[T any](v []T) List[T] {return List(v)}with the error: List(v) is not a typeIs this a bug, shortcoming of the current implementation, or by design? This would be a deal breaker if type-casting doesn't work for generics.
--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/NUDZ7gL-IIM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8c2a7b7d-ff11-4c8c-8dd4-2971ba6ab922n%40googlegroups.com.
aha, thanks for your help! One problem down.The error message is pretty cryptic though, I’d assumed the type inference would automatically take care of it, or complain about instantiation.
--On Feb 22, 2021, at 6:25 PM, Volker Dobler <dr.volke...@gmail.com> wrote:On Monday, 22 February 2021 at 15:03:53 UTC+1 Khosrow Afroozeh wrote:type List[T any] []T1. The current go2go implementation does not allow one to do this:func ToList[T any](v []T) List[T] {return List(v)}with the error: List(v) is not a typeIs this a bug, shortcoming of the current implementation, or by design? This would be a deal breaker if type-casting doesn't work for generics.Given that there are no type casts in Go this is absolutely to be expected ;-)And type conversions need a type and List isn't (but List[T] would be one).V.--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/NUDZ7gL-IIM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8c2a7b7d-ff11-4c8c-8dd4-2971ba6ab922n%40googlegroups.com.
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/2C15FD0D-933F-4CF7-AA88-686D232D38E0%40gmail.com.