#116 Improve const-correctness

closed
None
6
2011-03-19
2005-07-24
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/gnuplot/gnuplot/src/command.h?rev=1.37&view=markup
name (function "print_set_output")
s (functions "do_string.*")

-
http://cvs.sourceforge.net/viewcvs.py/gnuplot/gnuplot/src/eval.h?rev=1.21&view=markup
val (function "magnitude", "real", "imag" ...)

Discussion

1 2 > >> (Page 1 of 2)
  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    What we would like to do and what can realistically be
    achieved within the given code structure are, unfortunately,
    two different things. const correctness is really something
    that has to be designed into a program from the get-go to be
    manageable. gnuplot is way too old for that to have been
    the case, and the current team IMHO doesn't really have the
    manpower to spare on such issues.

     
  • Markus Elfring

    Markus Elfring - 2005-07-25
    • assigned_to: nobody --> broeker
     
  • Markus Elfring

    Markus Elfring - 2005-07-25

    Logged In: YES
    user_id=572001

    I hope that a const-correct design can be achieved also in
    your software by a refactoring process.

     
  • Markus Elfring

    Markus Elfring - 2005-07-26

    Logged In: YES
    user_id=572001

    Would you like to integrate the appended header files into
    your sources?

     
  • Hans-Bernhard Broeker

    Logged In: YES
    user_id=27517

    No. We can't do anything useful with modified versions of
    outdated header file revisions. If they were diffs to
    current CVS, that might be a different story.

    That set aside, changing header files doesn't fix anything
    yet --- it just renders the source uncompilable because of
    mismatches between prototype and definition.

     
  • Markus Elfring

    Markus Elfring - 2005-07-26

    Logged In: YES
    user_id=572001

    Would any other developer like to copy the suggested changes
    for the 4.0 headers to the current implementation files
    after your general safety checks and review?

     
  • Ethan Merritt

    Ethan Merritt - 2005-07-26

    Logged In: YES
    user_id=235620

    Instead of dumping modified versions of old headers, please
    tackle one or two subroutines at a time. For each set,
    submit a patch (diff -ur format) that updates the prototype
    definition, the subroutine itself, and all the call sites.

    That way there is some hope of testing for correctness of
    the individual pieces. The ones that pass muster can be
    added to cvs. The ones that fail can be sent back for
    further polishing.

     
  • Markus Elfring

    Markus Elfring - 2005-07-27
    • assigned_to: broeker --> sfeam
     
  • Markus Elfring

    Markus Elfring - 2005-07-27

    Logged In: YES
    user_id=572001

    1. Was it published before that only diffs will be accepted
    for further design considerations?

    2. Please confirm the correct path to the sources in the
    repository to avoid that "old" files or obsolete code
    branches will be reviewed.
    http://gnuplot.sourceforge.net/development/ethans_instructions.html

     
  • Ethan Merritt

    Ethan Merritt - 2005-07-27

    Logged In: YES
    user_id=235620

    1. Of course it is not required that you contribute anything
    at all. A suggestion with no code is also welcome. We are
    just saying that if you *do* care to contribute sample code,
    which is very much appreciated!, then it is most useful in
    the form of a "diff -ur" against the current cvs source
    tree. The code has changed sufficiently since version 4.0
    that diffs against earlier versions are unlikely to work.

    2. I don't understand this part of your question. The URL
    you refer to describes how to obtain a copy of the current
    cvs tree, which is what you should work with. But
    SourceForge is down right now so I cannot check to see if
    there is something on that URL that might be confusing.

     
  • Markus Elfring

    Markus Elfring - 2005-07-27

    Logged In: YES
    user_id=572001

    1. Thanks for this clarification.

    2. I try another wording ...
    Does the repository folder
    "http://cvs.sourceforge.net/viewcvs.py/gnuplot/gnuplot/src/"
    show the current 4.1.x development stage to which I refer to?
    (How can my proposed updates be identified as "modified
    versions of old headers"?)

     
  • Markus Elfring

    Markus Elfring - 2005-08-08

    differences from 27 changed files

     
    Attachments
  • Markus Elfring

    Markus Elfring - 2005-08-08

    Logged In: YES
    user_id=572001

    Would you like to check the appended changes for integration
    into the code?
    How are the changes for the proposed updates?

     
  • Ethan Merritt

    Ethan Merritt - 2005-09-18
    • status: open --> closed-wont-fix
     
  • Ethan Merritt

    Ethan Merritt - 2005-09-18

    Logged In: YES
    user_id=235620

    Doesn't compile due to type mis-matched caused by your changes.

    Typical case:
    command.c:188: error: conflicting types for 'print_out_name'
    command.h:88: error: previous declaration of
    'print_out_name' was here
    command.c:188: error: conflicting types for 'print_out_name'
    command.h:88: error: previous declaration of
    'print_out_name' was here
    command.c: In function `print_set_output':
    command.c:1119: warning: passing arg 1 of `free' discards
    qualifiers from pointer target type

    IMHO this particular project is a waste of time. If you
    want things to work on that will help the state of gnuplot
    code, I can give you a long list of things more important
    than the hypothetical compiler optimization associated with
    marking things as (const *).

     
  • Markus Elfring

    Markus Elfring - 2008-03-01

    update suggestion

     
    Attachments
  • Markus Elfring

    Markus Elfring - 2008-03-01
    • summary: Improve "const correctness" --> Improve const-correctness
    • status: closed-wont-fix --> open-later
     
  • Markus Elfring

    Markus Elfring - 2008-03-01

    Logged In: YES
    user_id=572001
    Originator: YES

    I dare another try for the current software.
    http://gnuplot.sourceforge.net/development/index.html

    Does the appended file contain acceptable changes?
    File Added: 4_3.diff.gz

     
  • Ethan Merritt

    Ethan Merritt - 2008-04-20

    Logged In: YES
    user_id=235620
    Originator: NO

    I have looked once more through the rationale for "const correctness", and find it unconvincing. I do not think this is a worthwhile goal.

     
  • Ethan Merritt

    Ethan Merritt - 2008-04-20
    • status: open-later --> closed-rejected
     
  • Markus Elfring

    Markus Elfring - 2008-04-20
    • status: closed-rejected --> open-later
     
  • Markus Elfring

    Markus Elfring - 2008-04-20

    Logged In: YES
    user_id=572001
    Originator: YES

    It has got the potential to uncover programming errors.
    How do you think about the proposed clean-up as a kind of documentation aid?

    My patch contains also a few adjustments for "size_t" handling.

     
  • Markus Elfring

    Markus Elfring - 2008-04-21

    Logged In: YES
    user_id=572001
    Originator: YES

    Do you support an API design clarification?
    Would you like to care for more specifications where pointers are used as (read-only) input parameters?

     
  • Ethan Merritt

    Ethan Merritt - 2008-09-04

    Logged In: YES
    user_id=235620
    Originator: NO

    This feature request has been closed because it is believed to be out of date. Possible reasons include (1) an equivalent feature is already present in the current cvs tree (2) a patchset implementing this feature has been submitted but has not yet made it into cvs (3) strong resistance to the request was expressed during discussion (4) we can't figure out what the request means

    If this is your request and you think that it is still relevant, please submit a revised version after trying out version 4.2 and the current CVS source.

     
  • Ethan Merritt

    Ethan Merritt - 2008-09-04
    • status: open-later --> closed-later
     
1 2 > >> (Page 1 of 2)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks