I'm sorry -- the "share" button doesn't seem to be working, or doesn't work 
in Firefox or Chrome.  And I have a window hung on "waiting for remote 
server," so I might have broken your playground.  

Here's my code in (hopefully) compileable form for your processor:

package main

impoort "strconv"

// Given:
func map(f(*), a []*, result []*) {
   for i, k := range a {
      result[i] = f(k)
   }
}

func main() {
   a := "a" ; aa := "aa"; aaa = "aaa"
   mylen := func(k *string) *int { 
      rv := len(*k)
      return &rv
   }
   map(mylen, []*string{&a, &aa, &aaa}, make([]*int, 3))  // Is this 
possible?

   one := 1; two := 2; three := 3
   myItoA := func(k *int) *string {
      rv := strconv.Itoa(*k)
      return &rv
   }
   map(myItoa, []*int{&one,&two,&three}, make([]*string, 3))  // once more, 
for profit

   map(strconv.Itoa, []*int{&a}, make([]*float, 1))     // Is this a 
runtime error?
}

And, yeah... the pointers are a bit of trouble.  By the time all of the 
wrapping and referencing is done, it's only a little easier than just using 
interface{} everywhere with casts.  If you don't get type safety with this, 
I feel like the syntactic sugar value is pretty modest.

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

Reply via email to