Why Objective-C doesn't support method overloading?

后端 未结 1 812
孤城傲影
孤城傲影 2020-12-06 02:22

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? <

相关标签:
1条回答
  • 2020-12-06 02:36

    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 讨论(0)
提交回复
热议问题