part of c programming
int* a = malloc(3 * sizeof(int)); a = {1, 2, 3};
currently, every declaration on the top-level of a file exists for all following code, even when the declaring file was only included. included library code can not hide helpers and internal declarations, type definitions, and macros. not only can this lead to naming conflicts when the following code tries to use an already declared identifier, it could also change the behavior unwantedly by declaring or modifying used bindings.
this makes it difficult to share libraries because some bindings, even if they are only used internally, may conflict with other libraries or the including codebase.
c can not rename bindings on inclusion. for example, the addition of a prefix to names that are too generic. redefinition and aliases are also no solution, as aliases require a reference to the aliased in the same scope.
currently, a common solution is to build shared library objects with header files and additional compilation configuration. this adds overhead which makes small libraries less practical to use. another approach is to use prefixes in identifiers to reduce the likelihood of the same name existing in including code.
if c had namespaces, there might be less need for configuring and compiling separate binary objects like modules because small libraries could be included without conflict.
for many types of resource allocation (for example, heap memory, file handles, database and network connections) the deallocation should not be missed because memory leaks, inefficient resource usage, and resource exhaustion would otherwise be the consequence. to track the life-time of such resources inside, outside, and through functions tends to create a considerable burden on the developer.
many related patterns emerge, for example:
automatic deallocation and more explicit syntax for passing resource handles between functions could help make programming easier and programs considerably more robust.
see also ownership in the rust language.