Re: Writing single bits to a file



"Martin Wells" <warint@xxxxxxxxxx> a écrit dans le message de news:
1193515386.951349.284640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Chqrlie:

And getting rid of these extra const qualifiers on the function
parameters
would improve readability, making parameter name mixup more obvious.

To be honest I'll use const wherever I can, unless it's stupid (and by
stupid I mean makes no difference whatsoever, or that the difference
has no benefits). An example of such a "stupid" case would be casting
to a const type, reason being that it doesn't make a difference
whether an R-value is const or not because you can't modify it anyway.
If I take a pointer as an argument to a function, and if I don't
intend on changing the pointer at all, then it makes sense to me to
declare it as const. Also, I don't find that it detracts form
readibility or that it adds confusion, so I suppose we just have
different opinions on this.

Given your choice of field names, you shouldn't be too proud of your coding
conventions, stylistic or otherwise. We do disagree on what you consider
'stupid' as well. IMHO, if the need arises to cast a qualified pointer to a
different type in an expression, needlessly unqualifying it at the same time
*is* stupid.

const qualifying the parameters of a 3 line function is completely useless.
Just like casting strcpy to (void) and casting the result of malloc().

--
Chqrlie.


.



Relevant Pages

  • Re: Is this legal ?
    ... >> to be followed again if the compiler can't guarantee that nothing that ... >address of an object into a pointer to const type version, ... to change it (by casting away const from a pointer to it, ...
    (comp.lang.c)
  • Re: is const necessary in eg int compar(const void *, const void *)
    ... void *' arguments to assign to a temporary pointer of the appropriate ... avoid casting. ... except that a pointer may be assigned to a _Bool. ... int by_age(const void *vsl, const void *vsr) ...
    (comp.lang.c)
  • Re: Writing single bits to a file
    ... To be honest I'll use const wherever I can, unless it's stupid (and by ... int main ... BitWriterFileInfo obj; ...
    (comp.lang.c)
  • Re: Writing single bits to a file
    ... 'stupid' as well. ... i = (int const)x; ... The be-all and end-all of it though is that I do be consistent with ... const -- i.e. if I'm don't plan on changing it, ...
    (comp.lang.c)
  • Re: (no) fast boolean evaluation ? missing NOT
    ... def Some_Function: ... print 'Ive been here', const ... and indeed I must have something very stupid!! ... Stef Mientki ...
    (comp.lang.python)