This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question


Przemyslaw Sliwa wrote:
All,

I was just wondering what means

double gsl_cdf_ugaussian_Pinv (const double P)

Correct me if I am wrong but it seems the const word is not required
in this case and we cannot change the value of P.


I think you are right, const is not required and you don't need to worry about it when calling the function. This is certainly true in C++.


Nonetheless, it is often a good idea to declare an automatic function parameter const in the function definition. This forces the compiler to check that you don't change the parameter value in the body of the function. Similarly, it is a good idea to declare any variable const if you don't intend to change it.

You can declare the function as

double gsl_cdf_ugaussian_Pinv (double);

and define it as

double gsl_cdf_ugaussian_Pinv (const double P){
...
}

but it may be better to make the two match precisely either because you may want to use some editing tools that rely on a match or because you want the code to work on a compiler that can't work oout that the declaration and definition do match.

--
JDL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]