go - Bodiless function in Golang -


reading source code of math/floor.go, starting line 13, read code this:

func floor(x float64) float64  func floor(x float64) float64 {     if x == 0 || isnan(x) || isinf(x, 0) {         return x     }     if x < 0 {         d, fract := modf(-x)         if fract != 0.0 {             d = d + 1         }         return -d     }     d, _ := modf(x)     return d } 

it seems func floor has no body. tried copy , paste these code in go file. doesn't compile. error message missing function body. question is: bodiless function legal in go's syntax? thanks.

it's way how functions implemented in assembly. find assembly implementation in floor_arch.s (e.g.: amd64) files.

to quote spec:

a function declaration may omit body. such declaration provides signature function implemented outside go, such assembly routine.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -