[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/5] qualify constant with the const

From: Marin Ramesa
Subject: Re: [PATCH 4/5] qualify constant with the const
Date: Mon, 16 Sep 2013 08:09:44 +0200

On 11.09.2013 22:14:49, Samuel Thibault wrote:
> Marin Ramesa, le Wed 11 Sep 2013 12:27:50 +0200, a écrit :
> > Function cnputc() should never modify it's argument so qualify it
> > with a const keyword.
> > 
> >  void
> >  cnputc(c)
> > -   char c;
> > +   const char c;
> Well, this is not really useful: the function gets a copy of the
> argument anyway.
> Samuel

Yes, but the const protects the copy. It expresses the intent of the 
function. It's like saying to the caller: "I will behave nicely and not 
modify the passed value during my execution." Then the caller knows 
that the value of the variable after the function is the same that was 
in the function.

But you're probably right in not applying this. It would mean changing 
half the functions in gnumach. In the future I will only qualify 
obvious constants with const.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]