开发者

Why Objective-C doesn't support method overloading?

开发者_C百科

Objective-C doesn't support methods overloading.

Why?

Is it doable but Apple decided not implement it? or it is not doable due the dynamic nature of Objective-C?

I have the impression that method overloading can be done on compiled languages (Java, C#) and can't be done on interpreted languages (Ruby, Python).

Holds some true?


The distinction that's relevant here is not between compiled and interpreted languages, but between statically typed (Java, C#) and dynamically typed (Ruby, Python, Objective-C). In a dynamically typed language, type information is very often not known until runtime. At runtime, all objects are statically typed as id in Objective-C.

Additionally, a core idea in dynamically typed OO languages is that you should not care what type an object is as long as it responds to the messages you want to send. So overloading based on type would fly right in the face of that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜