4 ms·
A closure is 1 function and an environment. An object is N functions and an environment. Objects are more useful as you don't need to repeat the environment to
by detrino 12y ago
A closure is 1 function and an environment.
An object is N functions and an environment.
Objects are more useful as you don't need to repeat the environment to implement more than 1 operation.
Both objects and closures can be type erased so that the environment is not part of their type.
- jusssi 12y agoThat single closure function could return e.g. a map containing more functions that share the same environment.