On Thu, 08 May 2014 07:29:08 +0000 bearophile via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com> wrote:
> Jonathan M Davis: > > > ultimately, this sort of > > thing pretty much always ends up being highly subjective. > > But please put the const/immutable of methods on the right: > > struct Foo { > void bar1() const {} // Good > const void bar2() {} // Bad > } Well, that's one case where there's actually an objective reason to put it on the right due to one of the flaws in the language - that it's the one place that const inconsistently does not apply to the type immediately to its right (though it's consistent with how attributes are applied to the function itself - just not consistent with variables). It's also because of this that I favor putting most attributes on the right (though that's subjective, unlike with const). I only put attributes on the left if they're on the left in C++ or Java (e.g. static, public, or final). Everything else goes on the right. Unfortunately, making this consistent by doing something like enforcing that all function attributes go on the right would then be inconsistent with other languages with regards to the attributes that they have which go on the left, so I don't know how we could have gotten it completely right. No matter which way you go, it's inconsistent in one way or another. If it were up to me, I'd probably enforce that all attributes which could be ambiguous go on the right but that all others could go on either side, but Walter has never liked that idea. So, we're stuck with arguing that everyone should put them on the right by convention in order to avoid the ambiguity. - Jonathan M Davis