5 ms·
One advantage of using multiple files is that you can have functions that are private to the file (static functions). So when looking at a specific file you kno
by nimrody 6y ago
One advantage of using multiple files is that you can have functions that are private to the file (static functions). So when looking at a specific file you know it can use either functions in this specific file or functions #include-d from other files. But it cannot use the private functions of other non-included files.
This reduces the cognitive load and gives the compiler a way to enforce separation.
In short - files in C can give you namespaces -- which are sometimes a useful way to organize code.
- kwhitefoot 6y agoIn Pascal you can define functions inside other functions. So if, as is often the case, the file consists of one public function that calls a number of private ones this can be enforced without needing to put them in separate files. In newer languages like C# you can do the same. Probably works in lots of other languages too, see Rosetta Code: Nested Function: https://rosettacode.org/wiki/Nested_function