[petsc-dev] declaring argument as const basic type in PETSc

Jed Brown jedbrown at mcs.anl.gov
Wed Aug 17 14:26:40 CDT 2011


On Wed, Aug 17, 2011 at 12:04, Chetan Jhurani <chetan.jhurani at gmail.com>wrote:

> void f(const int n, int* j)
> {
>    *j = n;
>    n = 0; // error
> }
>
> Of course it is more useful for preventing bugs in more complex
> functions.
>

This is a semantic of the implementation, not the interface, so it doesn't
belong in the interface. It's not truly meaningless, just meaningless to the
caller.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20110817/54f7008e/attachment.html>


More information about the petsc-dev mailing list