[resend lost message]

> From: Guy Harris <g...@alum.mit.edu>

> 
> On Mar 4, 2014, at 5:43 AM, François-Xavier Le Bail <fx.leb...@yahoo.com> 
> wrote:
> 
>>  Is it not better to add const in the propotype ?
> 
> In what cases, if any, are parameters that are const (rather than non-const 
> parameters that point to a const object) useful?

Even if doing that does not add anything to the interface, I think it can be
safer as it signals intent within the function: the parameter is read-only. 

> C is pass-by-value, so it's not as if the caller will see any changes the 
> callee makes - i.e., the caller has no reason to care.

Yes, I know that.
The usefulness is not for the caller but in the callee to indicates that
internally, the function does not modify the parameter.

> So declaring an argument as const amounts to a guarantee that the particular 
> variable in question will, throughout the function, have the value that was 
> passed in, so that somebody reading the code will know that it's not being 
> manipulated throughout the function and doesn't have to, in the case of 
> packet dissectors, think "wait, is this the length we were handed, or is it 
> the length of the part of the packet that we haven't yet dissected"?

Yes.

_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Reply via email to