(计算机)Method Signature

  1. 示例
    1. Java
    2. Go

Method Signature **或 **Function Signature 意思相似。Java 使用 Method Signature 区分 Method,该区分用于 Overloading (重载) 。在python的PEP 362,提到希望使用 Function Signature 进行更高效的 introspection (内省) 。

示例

Java

下面是一段Method代码

1
2
3
4
public double calculateAnswer(double wingSpan, int numberOfEngines,
                              double length, double grossTons) {
    //do the calculation here
}

这段代码对应的Method Signature是:

1
calculateAnswer(double, int, double, double)

Go

示例代码

1
2
3
4
5
6
7
8
func()
func(x int) int
func(a, _ int, z float32) bool
func(a, b int, z float32) (bool)
func(prefix string, values ...int)
func(a, b int, z float64, opt ...interface{}) (success bool)
func(int, int, float64) (float64, *[]int)
func(n int) func(p *T)