What does a function without body mean?

前端 未结 1 2077
花落未央
花落未央 2020-11-30 05:42

I\'m reading the code that package time, and then I want to know how the func After(d Duration) <-chan Time works.

I found the code f

相关标签:
1条回答
  • 2020-11-30 06:06

    1) The function is defined here:

    // startTimer adds t to the timer heap.
    //go:linkname startTimer time.startTimer
    func startTimer(t *timer) {
        if raceenabled {
            racerelease(unsafe.Pointer(t))
        }
        addtimer(t)
    }
    

    2) Function declarations:

    A function declaration may omit the body. Such a declaration provides the signature for a function implemented outside Go, such as an assembly routine.

    3) Not every programming language can express its own runtime entirely (C can, for example). Parts of the Go runtime and the standard library are in C, parts are in assembly while some other are in .goc, which is a not well documented hybrid of Go and C.

    0 讨论(0)
提交回复
热议问题