二级以上医院是什么意思| tdp是什么意思| 咪咪是什么| 张嘴睡觉是什么原因| 精是什么意思| 又什么又什么造句| 高考推迟月经吃什么药| 怪力乱神是什么意思| 甲减是一种什么病| 狗改不了吃屎是什么意思| 疝囊是什么| pf什么意思| 乙肝25阳性什么意思| 耳朵里面疼用什么药| 肝区回声密集是什么意思| 晚上九点多是什么时辰| 定坤丹什么时候吃最好| 吃过榴莲不能吃什么| 脑梗有什么症状| 腰疼挂什么科室| 细菌属于什么生物| 痛经是什么引起的| 什么植物驱蚊效果最好| 什么草地| 碧玺是什么| 妈祖属什么生肖| 霖五行属什么| 飞蚊症是什么原因| 正比和反比是什么意思| 什么鱼做酸菜鱼最好吃| 什么是嗳气有何症状| 去火喝什么茶| 怀孕孕酮低吃什么补得快| 百日咳是什么引起的| cpp是什么意思| 冷敷眼睛有什么好处| 洋葱什么时候种植| 万艾可是什么| 天顶星座是什么意思| 中国是什么时区| sheep是什么意思| 清除胃火吃什么药| 相对而行是什么意思| 男生生理期是什么表现| 茯茶是什么茶| 眼前发黑是什么原因| 1年是什么朝代| 互联网是干什么的| 强痛定又叫什么| 军加皮念什么| 打呼噜是什么原因引起的| 鸡皮肤是什么原因引起的| 什么治咳嗽最快最有效| 经常咬手指甲是什么原因| 三百多分能上什么大学| 什么是津液| 福建有什么好吃的| 重阳节是什么时候| 阿司匹林肠溶片治什么病| 胃不好吃什么水果好| 拾到什么意思| 灵芝孢子粉治什么病| 一九八八年属什么生肖| 九条鱼代表什么意思| 劫财是什么意思| nt宝宝不配合说明什么| 属牛男最在乎女人什么| 嚼槟榔为什么上瘾| 男鸡配什么属相最好| 岁月匆匆像一阵风是什么歌| 吃避孕药不能吃什么东西| 梦到自己掉头发是什么预兆| 开场白是什么意思| 阑尾炎做什么检查| 女性外阴瘙痒用什么药| 减肥期间吃什么水果| 什么是配速| 杀阴虱用什么药最好| 肚脐眼疼是什么原因| 4岁打什么疫苗| 大便次数多什么原因| 虎头蜂泡酒有什么功效| 吃什么补肺养肺比较好| 脚真菌感染用什么药| 何炅的老婆叫什么名字| 万马奔腾什么意思| 枪灰色是什么颜色| 蜂蜜喝了有什么好处| 尿道炎有什么症状| 膝关节疼痛挂什么科| 不将就是什么意思| 玫瑰花可以和什么一起泡水喝| 饕餮是什么| 七月初一是什么日子| 十三幺是什么意思| 颈椎病吃什么药好| 1987年属什么今年多大| 366是什么意思| 受害者是什么意思| 来姨妈头疼是什么原因| 乔迁是什么意思| 极核是什么| 黑眼圈严重是什么原因| 福泽深厚什么意思| 脚底板出汗是什么原因| 什么人不适合普拉提| 什么降血糖| 陶渊明是什么朝代| 车辆购置税什么时候交| 什么叫佛系| 路人皆知的上一句歇后语是什么| 胆红素尿呈什么颜色| 吃杏子有什么好处| 空调为什么不制冷| 什么是包皮| 什么人容易得格林巴利| 手指长水泡很痒是什么原因| 宫腔内高回声是什么意思| 低压高吃什么药好| 中午12点到1点是什么时辰| 白萝卜煮水喝有什么功效和作用| 女生是t是什么意思| 什么成什么就| 脸过敏要注意什么| 年上和年下是什么意思| 附属医院是什么意思| 水是什么意思| 市宣传部长是什么级别| 元参别名叫什么| 两特两重指的是什么| 血珀五行属什么| 蒲公英什么功效| 兜兜转转是什么意思| 签注是什么| 什么降肌酐| 沆瀣一气是什么意思| 曙光是什么意思| 佐匹克隆片是什么药| 1月10日什么星座| 1938年属什么生肖| 非那雄胺片是什么药| 幻和是什么意思| 监督的近义词是什么| 司空见惯的惯是什么意思| 觅食是什么意思| 龙涎是什么| 肺部占位性的病变指什么| 咳嗽应该挂什么科| 进国企需要什么条件| 肠胃功能紊乱吃什么药| 锌是什么| 口腔医学是干什么的| 感冒了吃什么饭菜合适| 尿酸高多吃什么食物好| only什么意思| 免疫力低有什么症状| 念力是什么意思| 海豹是什么动物| tp是什么| 什么是飞秒手术| 羊猄皮是什么皮| 四氯化碳是什么| 3月14日是什么星座| 冠状沟有溃疡是什么病| 左肺上叶肺大泡是什么意思| 隐翅虫是什么样子| 女生学什么专业好| 余田是什么字| 鳄鱼吃什么食物| 年收入10万什么水平| 比基尼是什么| 梦到捡钱是什么意思| 榴莲什么样的好| 腹泻不能吃什么食物| 苯甲酸钠是什么| 什么如泰山| 做梦梦到自己生病了是什么意思| 液体变固体叫什么| 厂昔念什么| 赵本山什么时候死的| 长白头发了吃什么才能把头发变黑| 柏拉图式是什么意思| 感性什么意思| 十三太保什么意思| 出汗多吃什么药| 傻瓜是什么生肖| 什么是强迫症| 厮守是什么意思| 每天流鼻血是什么原因| 大众什么车最贵| o2o是什么意思| 尾椎骨疼是什么原因| 诚不我欺什么意思| 脂肪粒是什么| 三叉神经痛吃什么药| 晚上吃什么能减肥| 脚痒用什么药膏最有效| 洗发水和洗发露有什么区别| 莲藕炒什么好吃| iris是什么意思啊| 丝状疣用什么药| 什么动物是爸爸生的| 肠胃炎可以喝什么饮料| 什么血型的人最多| 减肥期间吃什么主食| 什么花在什么时间开| 在屋顶唱着你的歌是什么歌| 西安属于什么省| 18年是什么婚| 贫血吃什么药最快| 脸上长斑是什么原因引起的| 剪刀石头布什么意思| 芽轴发育成什么| 双手抽筋是什么原因| 9月14号什么星座| 庖丁是什么意思| 梦见病人好了什么预兆| 小肚子发胀是什么原因女性| 鲤鱼爱吃什么食物| 含义是什么意思| 工薪阶层是什么意思| 欠缺是什么意思| 10月25号是什么星座| 吃避孕药为什么要吃维生素c| 李五行属性是什么| 什么是心脏早搏| 不除外是什么意思| 车厘子不能和什么一起吃| 什么匆匆| 孕妇梦见鱼是什么意思| 吝啬的意思是什么| 铜钱癣用什么药| 缺铁性贫血吃什么药| uva是什么意思| 不小心怀孕了吃什么药可以流掉| 天相是什么意思| 什么的动作| 疾控中心属于什么单位| 特别的意思是什么| 什么是透析| balmain什么档次| 油腻腻的什么| 急性扁桃体炎吃什么药| hcg低有什么补救的办法| 火龙果是什么颜色| 肾虚吃什么东西补得快| 豆浆喝多了有什么坏处| 涤是什么面料| 江小白是什么酒| 什么人容易得骨肿瘤| 吃什么水果可以降火| 刻板是什么意思| 幽门螺杆菌是什么症状| 大腿根疼挂什么科| 1926年属什么生肖| 九月什么星座| 晚上看见刺猬预示什么| 什么叫紫癜| 胎儿右肾盂分离是什么意思| 肠系膜脂膜炎是什么病| 洗手做羹汤是什么意思| 尿检ph值偏高说明什么| 白带褐色什么原因| 殊荣是什么意思| 百度Jump to content

政治献金案与“卡扎菲谜团”

From Wikipedia, the free encyclopedia
(Redirected from Function signature)
百度 ”(实习编译:任少华审稿:朱盈库)

In computer science, a type signature or type annotation defines the inputs and outputs of a function, subroutine or method.[citation needed] A type signature includes the number, types, and order of the function's arguments. One important use of a type signature is for function overload resolution, where one particular definition of a function to be called is selected among many overloaded forms.

Examples

[edit]

C/C++

[edit]

In C and C++, the type signature is declared by what is commonly known as a function prototype. In C/C++, a function declaration reflects its use; for example, a function pointer with the signature (int)(char, double) would be called as:

char c;
double d;
int retVal = (*fPtr)(c, d);

Erlang

[edit]

In Erlang, type signatures may be optionally declared, as:[1]

-spec function_name(type1(), type2(), ...) -> out_type().

For example:

-spec is_even(number()) -> boolean().

Haskell

[edit]

A type signature in Haskell generally takes the following form:

functionName :: arg1Type -> arg2Type -> ... -> argNType

Notice that the type of the result can be regarded as everything past the first supplied argument. This is a consequence of currying, which is made possible by Haskell's support for first-class functions; this function requires two inputs where one argument is supplied and the function is "curried" to produce a function for the argument not supplied. Thus, calling f x, where f :: a -> b -> c, yields a new function f2 :: b -> c that can be called f2 b to produce c.

The actual type specifications can consist of an actual type, such as Integer, or a general type variable that is used in parametric polymorphic functions, such as a, or b, or anyType. So we can write something like: functionName :: a -> a -> ... -> a

Since Haskell supports higher-order functions, functions can be passed as arguments. This is written as: functionName :: (a -> a) -> a

This function takes in a function with type signature a -> a and returns data of type a out.

Java

[edit]

In the Java virtual machine, internal type signatures are used to identify methods and classes at the level of the virtual machine code.

Example: The method String String.substring(int, int) is represented in bytecode as Ljava/lang/String.substring(II)Ljava/lang/String;.

The signature of the main method looks like this:[2]

public static void main(String[] args);

And in the disassembled bytecode, it takes the form of Lsome/package/Main/main:([Ljava/lang/String;)V

The method signature for the main() method contains three modifiers:

  • public indicates that the main() method can be called by any object.
  • static indicates that the main() method is a class method.
  • void indicates that the main() method has no return value.

Signature

[edit]

A function signature consists of the function prototype. It specifies the general information about a function like the name, scope and parameters. Many programming languages use name mangling in order to pass along more semantic information from the compilers to the linkers. In addition to mangling, there is an excess of information in a function signature (stored internally to most compilers) which is not readily available, but may be accessed.[3]

Understanding the notion of a function signature is an important concept for all computer science studies.

  • Modern object orientation techniques make use of interfaces, which are essentially templates made from function signatures.
  • C++ uses function overloading with various signatures.

The practice of multiple inheritance requires consideration of the function signatures to avoid unpredictable results. Computer science theory, and the concept of polymorphism in particular, make much use of the concept of function signature.

In the C programming language, a signature is roughly equivalent to its prototype definition.

In the ML family of programming languages, "signature" is used as a keyword referring to a construct of the module system that plays the role of an interface.

Method signature

[edit]

In computer programming, especially object-oriented programming, a method is commonly identified by its unique method signature, which usually includes the method name and the number, types, and order of its parameters.[4] A method signature is the smallest type of a method.

Examples

[edit]

C/C++

[edit]

In C/C++, the method signature is the method name and the number and type of its parameters, but it is possible to have a last parameter that consists of an array of values:

int printf(const char*, ... );

Manipulation of these parameters can be done by using the routines in the standard library header <stdarg.h>.

In C++, the return type can also follow the parameter list, which is referred to as a trailing return type. The difference is only syntactic; in either case, the resulting signature is identical:

auto printf(const char*... ) -> int;

C#

[edit]

Similar to the syntax of C, method signatures in C# are composed of a name and the number and type of its parameters, where the last parameter may be an array of values:[5]

void Add(out int sum, params int[] value);
[...]
Add(out sum, 3, 5, 7, 11, -1);  // sum == 25

Java

[edit]

In Java, a method signature is composed of a name and the number, type, and order of its parameters. Return types and thrown exceptions are not considered to be a part of the method signature, nor are the names of parameters; they are ignored by the compiler for checking method uniqueness.

The method signatures help distinguish overloaded methods (methods with the same name) in a class. Return types are not included in overloading. Only method signatures should be used to distinguish overloaded methods.[6]

For example, the following two methods have different signatures:

void doSomething(String[] x); // doSomething(String[])
void doSomething(String x);   // doSomething(String)

The following two methods both have the same signature:

int doSomething(int x);                   // doSomething(int)
void doSomething(int y) throws Exception; // doSomething(int)

Julia

[edit]

In Julia, function signatures take the following form:

commission(sale::Int, rate::Float64)::Float64

The types in the arguments are used for the multiple dispatch. The return type is validated when the function returns a value, and a runtime exception is raised if the type of the value does not agree with the specified type.

Abstract types are allowed and are encouraged for implementing general behavior that is common to all subtypes. The above function can therefore be rewritten as follows. In this case, the function can accept any Integer and Real subtypes accordingly.

commission(sale::Integer, rate::Real)::Real

Types are completely optional in function arguments. When unspecified, it is equivalent to using the type Any, which is the super-type of all types. It is idiomatic to specify argument types but not return type.

Objective-C

[edit]

In the Objective-C programming language, method signatures for an object are declared in the interface header file. For example,

- (id)initWithInt:(int)value;

defines a method initWithInt that returns a general object (an id) and takes one integer argument. Objective-C only requires a type in a signature to be explicit when the type is not id; this signature is equivalent:

- initWithInt:(int)value;

Rust

[edit]

In Rust, function signatures take the following form:

fn commission(sale: u32, rate: f64) -> f64;

See also

[edit]

References

[edit]
  1. ^ "Erlang Reference Manual User's Guide Version 13.1.4". erlang.org. 7.5 Specifications for Functions. Archived from the original on 2025-08-06. Retrieved 2025-08-06.
  2. ^ "Signature (functions) - MDN Web Docs Glossary: Definitions of Web-related terms | MDN". developer.mozilla.org. 2025-08-06. Retrieved 2025-08-06.
  3. ^ "C++ Reference: Programming terms". Retrieved 3 December 2013.
  4. ^ Paul Leahy. "Method Signature". About.com Guide. Retrieved 2025-08-06. A method signature is part of the method declaration. It is the combination of the method name and the parameter list.
  5. ^ M?ssenb?ck, Hanspeter (2025-08-06). "Advanced C#: Variable Number of Parameters" (PDF). Institut für Systemsoftware, Johannes Kepler Universit?t Linz, Fachbereich Informatik. p. 52. Retrieved 2025-08-06.
  6. ^ "Chapter 4. The class File Format". docs.oracle.com. Retrieved 2025-08-06.
裘皮是什么皮 胸小是缺少什么营养 为什么读研 补充蛋白质吃什么最好 感恩节什么时候
什么房不能住人 手脚软无力是什么原因引起的 黄色裤子配什么上衣 结界是什么意思 左手发麻是什么原因
神经是什么东西 造诣是什么意思 姨妈少是什么原因怎么办 沈阳六院主要治什么病 附骨疽在现代叫什么病
ac是胎儿的什么 得了破伤风是什么症状 淋巴细胞减少说明什么 鸡尾酒是什么意思 93属什么生肖
早晨起床口苦是什么原因gangsutong.com 凶是什么生肖hcv8jop5ns5r.cn 舌头边上有锯齿状是什么原因hcv9jop4ns5r.cn 为什么人hcv8jop1ns9r.cn un读什么hcv9jop0ns7r.cn
aigner是什么牌子hcv9jop0ns1r.cn 尽兴是什么意思hcv7jop9ns5r.cn peep是什么意思clwhiglsz.com 黄色鞋子配什么颜色裤子aiwuzhiyu.com 一什么之什么成语hcv8jop2ns5r.cn
敬谢不敏什么意思hcv8jop8ns3r.cn pumpkin是什么意思hcv9jop8ns0r.cn 嗜酸性粒细胞是什么hcv8jop0ns1r.cn 乌龟白眼病用什么药hcv8jop0ns8r.cn 声东击西是什么意思yanzhenzixun.com
鼻子有痣代表什么hcv8jop5ns3r.cn 什么叫等离子hcv9jop0ns5r.cn fdg是什么意思hcv8jop6ns8r.cn 啤酒兑什么饮料好喝clwhiglsz.com 韭菜补什么hcv8jop1ns6r.cn
百度