Hi all, Inspired by a blog text, I've spent some time adding "const" in a number of places. Adding const tends to spiral out of control if it was not used when code was written, meaning that you will have to add const in many other places where it should have been when it was first written.
Please be very aggressive in adding "const" to any code you write. It will help us understand code better and will prevent bugs from creeping in.
If "const" is new to you or you're a bit rusty on the topic, read this: http://www.cprogramming.com/tutorial/const_correctness.html
Thanks a bunch, Cheers, Johan
On Jan 17, 2013, at 12:15 PM, Johan Engelen wrote:
Hi all, Inspired by a blog text, I've spent some time adding "const" in a number of places. Adding const tends to spiral out of control if it was not used when code was written, meaning that you will have to add const in many other places where it should have been when it was first written.
Please be very aggressive in adding "const" to any code you write. It will help us understand code better and will prevent bugs from creeping in.
If "const" is new to you or you're a bit rusty on the topic, read this: http://www.cprogramming.com/tutorial/const_correctness.html
Nice job!
Also that article is a handy reference on const.
Expanding on your point a bit, everyone should keep in mind that it is very easy to remove const later on, but very hard to add it.
One thing the article mentioned was that const can go on either side of a type. However once you get into references and pointers and such with C++, you generally read those from right-to-left. So it makes the code a little more legible if the 'const' comes between the variable type and name.
int const foo; RTL reading gives "foo is a constant int".
And then
int const & foo; RTL reading gives "foo is a reference o a constant int"
int const * foo; RTL reading gives "foo is a pointer to a constant int"
whereas
int * const foo; RTL reading gives "foo is a constant pointer to an int"
More possibly interesting reading - http://yosefk.com/c++fqa/const.html
Jevon
On Fri, Jan 18, 2013 at 9:15 AM, Johan Engelen <jbc.engelen@...2592...> wrote:
Hi all, Inspired by a blog text, I've spent some time adding "const" in a number of places. Adding const tends to spiral out of control if it was not used when code was written, meaning that you will have to add const in many other places where it should have been when it was first written.
Please be very aggressive in adding "const" to any code you write. It will help us understand code better and will prevent bugs from creeping in.
If "const" is new to you or you're a bit rusty on the topic, read this: http://www.cprogramming.com/tutorial/const_correctness.html
Thanks a bunch, Cheers, Johan
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_122712 _______________________________________________ Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
participants (3)
-
jevon
-
Johan Engelen
-
Jon Cruz