On Apr 20, 2014, at 1:32 PM, Mark Rowe <[email protected]> wrote: > > It’s also not possible to determine from context alone whether #if or if > should be used. When #if is used to remove members or functions you’re then > forced to use #if, rather than if, around all uses of those members or > functions since the alternative won’t compile. > > An example lifted from Vector.h: > > #if !ASSERT_DISABLED > template<typename T> struct ValueCheck<Vector<T>> { > typedef Vector<T> TraitType; > static void checkConsistency(const Vector<T>& v) > { > v.checkConsistency(); > } > }; > #endif > > template<typename T, size_t inlineCapacity, typename OverflowHandler> > inline void Vector<T, inlineCapacity, OverflowHandler>::checkConsistency() > { > if (!ASSERT_DISABLED) { > for (size_t i = 0; i < size(); ++i) > ValueCheck<T>::checkConsistency(at(i)); > } > } > > > This won’t compile with assertions disabled because > ValueCheck::checkConsistency doesn’t exist.
Oops, I should have read this email before sending my previous reply. It does seem like using if() exclusively to control assertions won’t work. On Apr 20, 2014, at 2:02 PM, Filip Pizlo <[email protected]> wrote: > The #if means that the code being guarded isn't indented. I believe that > indenting control flow is a good idea. This is the main reason I thought the proposal was promising. Note though that we could change our style guide to call for some indentation of #if’s if we wanted to. It is valid C/C++ to do so. The main is that not all text editors have good support for this. Regards, Maciej
_______________________________________________ webkit-dev mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-dev

