#1 Improve "const correctness"

open
nobody
None
5
2007-03-29
2005-07-24
Markus Elfring
No

Would you like to apply the advices from the article
"http://en.wikipedia.org/wiki/Const_correctness" to
your sources?
I suggest to add the key word "const" to the type
specifiers for parameters like the following.
- input (function "store")

http://cvs.sourceforge.net/viewcvs.py/vtd-xml/ximple-dev_c/vtd-xml/contextBuffer.h?rev=1.4&view=markup

- vn (functions "getAttr.+", "match.+")
vn, attrName (function "hasAttr")
vn, URL, localName (function "hasAttrNS")

http://cvs.sourceforge.net/viewcvs.py/vtd-xml/ximple-dev_c/vtd-xml/vtdNav.h?rev=1.9&view=markup

Discussion

  • jimmy zhang
    jimmy zhang
    2005-10-01

    Logged In: YES
    user_id=1051699

    Interesting suugestion, will think about that. Sorry for the
    late reply

     
  • jimmy zhang
    jimmy zhang
    2007-03-26

    • status: open --> closed
     
  • Markus Elfring
    Markus Elfring
    2007-03-27

    • status: closed --> open
     
  • jimmy zhang
    jimmy zhang
    2007-03-28

    • status: open --> pending
     
  • jimmy zhang
    jimmy zhang
    2007-03-28

    Logged In: YES
    user_id=1051699
    Originator: NO

    as far as I understand it, C doesn't support "const."

     
  • Markus Elfring
    Markus Elfring
    2007-03-28

    Logged In: YES
    user_id=572001
    Originator: YES

    Where did you get this kind of knowledge?
    "const" is a C key word.

     
  • Markus Elfring
    Markus Elfring
    2007-03-28

    • status: pending --> open
     
  • jimmy zhang
    jimmy zhang
    2007-03-29

    Logged In: YES
    user_id=1051699
    Originator: NO

    hmmm... I checked again, it is in fact a C keyword. are you
    suggesting that all #define should be declared "const."

     
  • jimmy zhang
    jimmy zhang
    2007-03-29

    • status: open --> pending
     
  • jimmy zhang
    jimmy zhang
    2007-03-29

    Logged In: YES
    user_id=1051699
    Originator: NO

    hmmm... I checked again, it is in fact a C keyword. are you
    suggesting that all #define should be declared "const."

     
  • Markus Elfring
    Markus Elfring
    2007-03-29

    Logged In: YES
    user_id=572001
    Originator: YES

    No, not all. I indicated some candidates for an API clarification.
    Do you see the situation that all interfaces might be affected?

    Do you want to consider the C99 key word "inline" instead of "#define"?
    http://en.wikipedia.org/wiki/Inline_expansion

     
  • Markus Elfring
    Markus Elfring
    2007-03-29

    • status: pending --> open