4 ms·
You can have an encapsulated object that is immutable and is not a bag of static functions anymore than any object is a bag of static functions. Look at Scala's
by sreque 7y ago
You can have an encapsulated object that is immutable and is not a bag of static functions anymore than any object is a bag of static functions. Look at Scala's interfaces for immutable collections.
* they are encapsulated. You don't know how the data is stored internally.
* There is message passing involved (at the JVM level). The methods are virtual and you don't know exactly which method is being called. There can also be multiple implementations using different data structures.
* Late binding is again as defined by the JVM (interface table method lookup)
In contrast, a static function is no different than a global variable. When you call it, you know exactly (sans JVM linking) which function you are calling.