|
|
|
|
|
by newsoul
1458 days ago
|
|
> And even then, most functional languages provide persistent data structures that allow efficient sharing of the unchanged parts of the data structure. So you are saying that in imperative setting if we use the original data for multiple functions we have to create copies of it and then modify those copies. So we end up taking extra space there also. So both languages take up space. One before the function call another after. |
|
Imperative usually goes with mutation. If I'm willing to do mutation, then I can replace the old value with the new value in the same location, allocating nothing either before or after.
If you want to do immutable with imperative, then yes, you have to allocate sometime.