std.compress

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Jun 10 07:53:13 PDT 2013


On 6/10/13 3:13 AM, Jacob Carlborg wrote:
> On 2013-06-10 04:33, Andrei Alexandrescu wrote:
>
>> Guys, they're function local vars. A comment would suffice.
>
> That doesn't mean the names should be less understandable. We're writing
> open source here. I think most names should be named as if they were
> part of the public API.

That's an exaggeration. There are plenty of obscure details that help 
implementers but would be unnecessary to publish with the API.

> It also depends on in what context they are used. Example, in DMD there
> are a lot of functions containing probably more the 500 lines of code
> with variable names with only one letter, declared at the top of the
> function. If you instead have a function with only five or ten lines of
> code it could be ok:
>
> private void foo (ProductInformation pi) { // five lines of code }
>
> I would think the above would be ok. But it should definitely not be
> used in documentation/examples as I see it is now.
>
> BTW, I hate using comments for that. Comments should basically only be
> used for writing API documentation. Most times, if you want to add a
> comment your code is probably not clear enough.

A lot of scientific code would be worse off if it used long variable 
names. Oftentimes it uses "tau" or "gamma" or even "a" or "k" with an 
explanatory comment at the top.


Andrei


More information about the Digitalmars-d mailing list