Call function in loop

Hi

I’m a new arrival of golang. Recently when I write something, I meet a weird problem that, the code written like
> // scanFunc is a closure

	for pos := scanFunc(list[beg:end]) ; middle != pos ; pos = scanFunc(list[beg:end]) {
            fmt.Printf("Scan %v, %v, result %v\n",beg,end,pos)
  if middle < pos {
  	end = pos + 1
  }else{
  	beg = pos
  }
  middle = ( beg + end  ) / 2

}

causes an extremely long time to compile before running, and the debug info are not printed.

I suppose that my because golang expand the function call during compile time, then the value of beg and end are fixed but not computed real-time, but I’m not sure about that.

Does anybody have some idea about that?

Never heard of something like that. Post a full example, and the steps you take to compile? If that’s not what you’re doing already, use go install.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.