Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Applied To HEAD Re: [cdt-patch] default code templates


Thanks Keith.

Defaults are cached, so if you did not find the new templates, please restore defaults and it will appear.

Hoda Amer
Staff Software Engineer
Rational Software - IBM Software Group



Keith Campbell/Ottawa/IBM@IBMCA
Sent by: cdt-patch-admin@xxxxxxxxxxx

02/06/2004 11:43 AM

Please respond to
cdt-patch

To
cdt-patch@xxxxxxxxxxx
cc
Subject
[cdt-patch] default code templates





Hello everyone.

It's my turn to pick nits. :-)

I propose we change the default code templates to use the pre-increment
operator explicitly rather than hoping that the compiler will recognize
that the post-increment operator can be replaced by the pre-increment
operator (at least for POD types).

It's always been a pet peeve of mine that too many people (even
well-respected authors) use post-increment (or decrement) needlessly.
Compilers are probably smart enough to fix this for POD types but can't
legally do so for class types. In those cases more work is done than is
needed. Let's lead by example.

-Keith
------

Index: src/org/eclipse/cdt/internal/corext/template/default-templates.xml
===================================================================
retrieving revision 1.3
diff -u -r1.3 default-templates.xml
--- src/org/eclipse/cdt/internal/corext/template/default-templates.xml  22
Dec 2003 21:12:45 -0000 1.3
+++ src/org/eclipse/cdt/internal/corext/template/default-templates.xml  6
Feb 2004 16:21:30 -0000
@@ -10,13 +10,13 @@
<!-- C++ -->

<template description="for loop" name="for" context="C Function">
-for (${var} = 0; ${var} &lt; ${max}; ${var}++) {
+for (${var} = 0; ${var} &lt; ${max}; ++${var}) {
       ${cursor}
}
</template>

<template description="for loop with temporary variable" name="for"
context="C Function">
-for (int ${var} = 0; ${var} &lt; ${max}; ${var}++) {
+for (int ${var} = 0; ${var} &lt; ${max}; ++${var}) {
       ${cursor}
}
</template>

_______________________________________________
cdt-patch mailing list
cdt-patch@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/cdt-patch


Back to the top