Re: When to use const modifier?



Antoninus Twink wrote:
On 3 Jun 2008 at 14:03, Walter Roberson wrote:
Richard <rgrdev@xxxxxxxxx> wrote:
So why dont you bother to actually understand what they do mean?
How should I prioritize this against the many many other tasks
that I have to do? Would you say that this is more important
or less important than feeding the dog? Is it important enough that
I should take a vacation week in order to study and practice it?
Do I have time for a shower before I start?

If you want to be a professional C programmer, then of course you need
to understand the basic features of the C language. Even if you refuse
to use them yourself, then you'll undoubtedly run across other people's
code, and they might not have the same prejudices as you against
features introduced into the C standard after the end of the cold war.

Certainly const is something you see all over the place in other
people's code; admittedly restrict is much rarer, but it does crop up in
certain libraries that want to Do Things Right.

I find it pretty amazing that you and Sossman, who are appalled if
people don't keep at the front of their mind that "long unsigned int
long" is a synonym for "unsigned long long", or fail to account for the
behavior of their code on a machine with no stack where fopen always
returns NULL, and generally seem content to waste hours of your time
pouring over the pointless minutiae of the dustier corners of the ANSI
Bible, should be so reluctant to figure out what const means.

Not only have you misspelled me, you have misconstrued me.
My understanding of `const' is sufficient to handle the cases
I've seen, although I confess that I need to stop and think
twice about some declarations.

If you would care to write a tutorial on `restrict' I'd be
interested in reading it and remedying some of my deficiencies.
However, if you can do no better with `restrict' than McLean
did with `const', don't bother.

--
Eric.Sosman@xxxxxxx
.



Relevant Pages

  • Re: When to use const modifier?
    ... How should I prioritize this against the many many other tasks ... to understand the basic features of the C language. ... people don't keep at the front of their mind that "long unsigned int ... should be so reluctant to figure out what const means. ...
    (comp.lang.c)
  • Re: For the CComBSTR lovers
    ... unsigned int ByteLength() const throw ... operator BSTR() const throw ... HRESULT __cdecl Formatthrow{va_list args; ...
    (microsoft.public.vc.atl)
  • Re: Object-oriented programming in standard ANSI C
    ... const Point* ... typedef struct Circle { ...
    (comp.lang.c)
  • Re: Hooking D3Device8 by replacing the VTable fails. Info needed.
    ... pointers. ... int,struct IDirect3DSurface9 *) unsigned long * ... *,struct tagRECT const *,unsigned long) unsigned long * ... _D3DPRIMITIVETYPE,unsigned int,void const *,unsigned int) unsigned long * ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Hooking D3Device8 by replacing the VTable fails. Info needed.
    ... Private in my jargon only means the public interface supplied in the ... int,struct IDirect3DSurface9 *) unsigned long * ... *,struct tagRECT const *,unsigned long) unsigned long * ... _D3DPRIMITIVETYPE,unsigned int,void const *,unsigned int) unsigned long * ...
    (microsoft.public.win32.programmer.directx.graphics)