3 ms·
> For example: in Java, methods with the same name but different argument types ("overloaded") are statically bound; whereas in Smalltalk, they are dynamically
by jonhohle 18y ago
> For example: in Java, methods with the same name but different argument types ("overloaded") are statically bound; whereas in Smalltalk, they are dynamically bound.
In Smalltalk you simply have messages. An object either responds to one or it doesn't, there's no concept of overloading. A method that looks the same, but has a different number of arguments is a different method.
For example, in Java you might have a print method which takes a string, or a method with the same name which takes a format string and a variable number of replacements:
String print(String s) { ... }
String print(String s, Object... v) { ... }
Same name, different signatures.
In Smalltalk, those methods would have different names:
print:f [...]
print:f args:v [...]
Where the names of the methods are print: and `print:args:` respectively.
Smalltalk generally closer to Python than C in terms of performance.