Hi

Am 14.07.2015 um 16:19 schrieb Joshua Cranmer 🐧:
> On 7/14/2015 1:39 AM, Thomas Zimmermann wrote:
>> When writing code, I consider it good style to not write into
>> anything that starts with an 'a' prefix, except result arguments.
>
> "You should never write into something with an 'a' prefix except when
> you should," if you simplify it. I've actually avoided using the a
> prefix for outparams precisely because it feels more consistent to
> never assign to a variable with an a value (and also because it
> distinguishes between Foo *aInArray and Foo *outparam), yet I did see
> someone upthread praising that it helped you see which values were
> outparams.

As I said above, I'd support introducing a separate prefix for output
parameters. And consequently enforcing the no-a-writes policy in reviews.

>
>> Makes the code cleaner, more readable, and often gives it a clear
>> structure. When reading the code later on, it's easy to spot the
>> parts of a the code that directly depend on external parameters by
>> looking for 'a' and 'm' prefixes.
>
> This, I feel, is an aspiration which is not supported by any of the
> code I work on (which admittedly is heavily COMtaminated). Any
> intuition about a difference between aFoo and foo in terms of "relies
> on arguments" is bound to be wrong.

I agree in general, but there are a number of conventions for special
symbols: prefixes, all-capitals, start-with-capital, etc. Each helps to
structure the code and make it more readable. That doesn't mean that the
other symbols are unimportant. I never claimed that it's possible to
understand code without actually reading it.

>
>
> Given that the aFoo rule is one of the least adhered-to portions of
> our style guide, and has been for as long as I've worked on Mozilla
> code; that the ancillary rule of "don't assign to an argument" has
> also been ignored on quite a few occasions; and that there hasn't been
> any real history of people complaining about the lack of adherence to
> this style guide point, I rather suspect that whatever people might
> say in how useful the 'a' prefix is, they get along quite fine without
> it.
>

In such cases, I always wonder why the coding style is incorrect.

The discussion has a number of good points in favor of using 'a', but I
missed convincing arguments in favor of not using 'a'. Are there any? I
don't consider "I don't get what 'a' is good for" a convincing argument.

Best regards
Thomas
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to