Hi, On Monday, June 13, 2016 at 9:41:52 AM UTC-4, charr...@gmail.com wrote: > > for reference, here is the mymap() > > http://tsoh.host/test.html#8e4ae712 > > it simply runs the callback on every slice member >
I apologize; I didn't communicate my question well. Your map example functions on a single type; is the implementation *restricted* to a single type? In a given scope, do all instances of "*" have to refer to the same type, or can it refer to multiple types? If the latter, how do you ensure type safety? How does this work: // Given: func map(f(*), a []*, result []*) { for i, k := range a { result[i] = f(k) } } map(len, []*string{"a","aa","aaa"}, make([]*int, 3)) // Is this possible? map(strconv.Itoa, []*int{1,2,3}, make([]*string, 3)) // once more, for profit map(strconv.Itoa, []*int{"a"}, make([]*float, 1)) // Is this a runtime error? Note these wouldn't work because the stdlib functions don't work on pointers, which is an unfortunate limitation. It would necessitate wrapping (nearly) every stdlib function that you wanted to use with this. I left out the wrappers for brevity, and yes, I'm throwing away the results. Just trying to head off the pedants. I'm unable to use your playground at the moment; I'm getting an "error communicating with remote server," so I can't test what happens. --- SER -- 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.