#24 Improve "const correctness"

open
Ludwig Nussel
None
5
2005-08-19
2005-08-17
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 examples.
-
http://cvs.sourceforge.net/viewcvs.py/xqf/xqf/src/launch.h?rev=1.1.1.1&view=markup
forkit, dir, argv (function "client_launch_exec")

-
http://cvs.sourceforge.net/viewcvs.py/xqf/xqf/src/flt-player.h?rev=1.3&view=markup
name, mask (function "player_filter_add_player")

-
http://cvs.sourceforge.net/viewcvs.py/xqf/xqf/src/pixmaps.h?rev=1.24&view=markup
pixmap (functions "pixmap_height", "pixmap_width")
s1, s2 (function "cat_pixmaps")

-
http://cvs.sourceforge.net/viewcvs.py/xqf/xqf/src/source.h?rev=1.6&view=markup
address (function "get_master_query_type_from_address")

-
http://cvs.sourceforge.net/viewcvs.py/xqf/xqf/src/statistics.h?rev=1.2&view=markup
s, versionstr (function ".*identify_.+")

Discussion

  • Ludwig Nussel
    Ludwig Nussel
    2005-08-18

    • assigned_to: nobody --> l-n
    • status: open --> closed
     
  • Ludwig Nussel
    Ludwig Nussel
    2005-08-18

    Logged In: YES
    user_id=333900

    well, go ahead and create a patch :-)

     
  • Markus Elfring
    Markus Elfring
    2005-08-19

    differences from 10 changed files

     
    Attachments
  • Markus Elfring
    Markus Elfring
    2005-08-19

    • status: closed --> open
     
  • Markus Elfring
    Markus Elfring
    2005-08-19

    Logged In: YES
    user_id=572001

    Are you going to integrate the proposed corrections into the
    code?

    Would you like to accept the appended update package?

     
  • Ludwig Nussel
    Ludwig Nussel
    2005-08-20

    Logged In: YES
    user_id=333900

    I prefer const before the type name

     
  • Markus Elfring
    Markus Elfring
    2005-08-20

    Logged In: YES
    user_id=572001

    You can adjust the key word ordering to your preferences.

    I apply the right-to-left reading direction for function
    arguments/parameters.
    The rationale for my modifier ordering can be found in the
    article "Const Correctness Part 4" by Darren Collins.
    http://codecraft.pool-room.com/Cpp/const-correctness-4.html