|
From: Ivo R. <iv...@iv...> - 2016-12-23 03:02:01
|
2016-12-21 17:08 GMT+01:00 John Reiser <jr...@bi...>: > On 12/21/2016 12:57 AM, Ivo Raisr wrote: > > > Are there any objections to the changes for this bug: > > https://bugs.kde.org/show_bug.cgi?id=373938 > > > > The gist of my changes is really just: > > - Bool matchIRExpr ( MatchInfo* mi, IRExpr* p, IRExpr* e ); > > + Bool matchIRExpr ( MatchInfo* mi, const IRExpr* p, const IRExpr* e ); > > I applaud the use of 'const' as often as possible. > It increases understanding and reduces debugging and maintenance costs > because it reduces the places where values can change. > It also tells the compiler where aggressive optimization is possible. > > I believe that 'const' should appear as far to the right as possible: > > IRExpr const *p > > This makes declarations easier to read. Declarations are read > from the inside to the outside; this means right-to-left > (except for function names and order of parameters.) > In the example, what is 'p'? > > spoken or read: p is a pointer to a const IRExpr > transliterated: p * const IRExpr > proper syntax: IRExpr const *p > > This placement of 'const' is especially natural in C++, > where the spoken "by const-ref" becomes the syntax "const&". > Thank you for detailed explanation of your arguments. I think consistency with the rest of VEX code is also important. I did a little research and nowhere in VEX we can see 'T const *'; it is always 'const T *'. I. |