4 ms·
Fortran also has an interesting pattern of dealing with memory, in that everything is passed by reference between functions, yet there is no need to manually ma
by cbcoutinho 8y ago
Fortran also has an interesting pattern of dealing with memory, in that everything is passed by reference between functions, yet there is no need to manually manage memory like you would need to in C/C++.
I've never seen code where you need to deal with malloc et al. You are able to create dynamically allocated arrays or let arrays be sized on evocation, but I've never needed to deallocate or free memory at the end of a function/subroutine.
- gnufx 8y agoThis comes up most times Fortran is mentioned, but it is not true that Fortran passes by reference, and optimizations rely on that fact. The rules around storage association are typically referred to as pass by value-return or copy-in/copy-out. It's misleading to imply you never have to free memory. The NAG compiler runtime includes Boehm's conservative garbage collector (or did, last I checked) for a reason.