Const (computer programming): Difference between revisions

Content deleted Content added
Reverted good faith edits by Afitterling (talk): This is already mentioned in section 'Other languages' (does not need to be in the lead section)
m History: archive link repair, may include: archive.* -> archive.today, and http->https for ghostarchive.org and archive.org (wp:el#Specifying_protocols)
Line 341:
The first use, as a scoped and typed alternative to macros, was analogously fulfilled for function-like macros via the <code>inline</code> keyword. Constant pointers, and the <code>* const</code> notation, were suggested by Dennis Ritchie and so adopted.<ref name="siblings" />
 
<code>const</code> was then adopted in C as part of standardization, and appears in [[ANSI C|C89]] (and subsequent versions) along with the other type qualifier, <code>volatile</code>.<ref>[[Dennis M. Ritchie]], "[http://cm.bell-labs.com/who/dmr/chist.html The Development of the C Language] {{webarchive |url=https://archive.istoday/20120715050501/http://cm.bell-labs.com/who/dmr/chist.html |date=July 15, 2012 }}", 2003: "X3J11 also introduced a host of smaller additions and adjustments, for example, the type qualifiers '''const''' and '''volatile''', and slightly different type promotion rules."</ref> A further qualifier, <code>noalias</code>, was suggested at the December 1987 meeting of the X3J11 committee, but was rejected; its goal was ultimately fulfilled by the <code>[[restrict]]</code> keyword in [[C99]]. Ritchie was not very supportive of these additions, arguing that they did not "carry their weight", but ultimately did not argue for their removal from the standard.<ref>"Let me begin by saying that I'm not convinced that even the pre-December qualifiers ('const' and 'volatile') carry their weight; I suspect that what they add to the cost of learning and using the language is not repaid in greater expressiveness.
'Volatile', in particular, is a frill for esoteric applications, and much better expressed by other means. Its chief virtue is that nearly everyone can forget about it. 'Const' is simultaneously more useful and more obtrusive; you can't avoid learning about it, because of its presence in the library interface. Nevertheless, I don't argue for the extirpation of qualifiers, if only because it is too late."</ref>