Liste des Groupes | Revenir à cl c |
On 21/06/2024 14:51, David Brown wrote:Namespace pollution. C does not have namespaces, so everything gets dumped in the global namespaces. There is always a risk that user code has identifiers that are used by later versions of the C standards, even when they try to avoid the names in the reserved list. As each standard gets more standard headers, and more identifiers in them, the risk of conflicts if you always included all standard headers would be huge.On 21/06/2024 15:25, bart wrote:Such as? It can't be compilation time, since headers ten times the size or more apparently instantly.(Which is why I think they should just be included anyway.)>
That would be a terrible idea for many reasons.
One delight in using my language is that its standard library is always available. But if you don't want it, it can be disabled. With C I spend a big chunk of my time writing include lines.That sounds like inefficient coding practices. You do know that file inclusion is recursive? So if most of the files in your project use <stdbool.h>, <stdint.h>, <stdlib.h>, <stddef.h> and <string.h>, you can put all these in a file "common.h" and include that? But if you never, or almost never, use <setjmp.h>, <complex.h>, <wctype.h>, <fenv.h>, then you don't bother with them in the "common.h" file.
First I need stdio. Then string. Then stdlib. Then there's always ones I can't quite remember.There are some pretty good references available. Some compilers will even tell you which include files are missing, at least in some common cases.
Or I need to debug someone's code, and it needs stdio to define 'printf', FFS. Would the world stop turning if it was just available?I sometimes want to define my own "printf". You can disagree, but certainly /I/ am glad of the flexibility C offers.
I just don't believe that things defined in the headers need to be micro-managed to that extent, most of the time.Most languages require declarations of libraries or modules that are used. C, being fairly low-level and with a smaller core language than most, might require such declarations a little more than most languages. But it works well enough in practice.
Les messages affichés proviennent d'usenet.