Strictness of language styling

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Nov 10 14:00:32 PST 2014


On Mon, Nov 10, 2014 at 11:27:13PM +0200, ketmar via Digitalmars-d-learn wrote:
> On Mon, 10 Nov 2014 11:35:04 -0800
> "H. S. Teoh via Digitalmars-d-learn"
> <digitalmars-d-learn at puremagic.com> wrote:
> 
> > I have to say that I *hate* camelCase... it looks really ugly. But
> > what looks uglier is a mixture of camelCase and something else. And
> > since Phobos is all camelCased, and almost all D code uses Phobos,
> > writing your own code with something else makes it doubly ugly. So
> > nowadays I just use Phobos style for my own code. :-P  Nevertheless,
> > I still dislike camelCase.
>
> that's why i recommending camelCase. not because it's better, it's
> just happens. ;-)

I'd rather use underscore_separated_words any day, than
havingAllWordsSmushedTogetherIntoOverlyLongIdentifiers that makes my
eyes bleed.

But mixing Phobos camelCase with underscored_identifiers makes my eyes
bleed even more, so it's at least tolerable.


> yet i can't go that far to drop my egyptian brackets or use four
> spaces for indentation.

I used to be an Egyptian-braces / tabs-only-indentation advocate. That
works reasonably well in C/C++, but I find that with idiomatic D, Phobos
style actually works much better. (Well, except that horrid camelCasing,
but hey, you can't win every battle.)  D code tends to require many more
levels of indentation than C/C++, so using tabs can be quite cumbersome.
also, Egyptian braces tend to work better when the leading line of
nested blocks is simple, but in D, esp. with the complexity of function
declarations, the opposite is true.

But at least none of us use the following bracing style, which I had the
misfortune of coming across many years ago (I kid you not, people
actually exist who write code like this):

	int my_func(int arg) {
		if (arg==1) {
			printf("One\n");
			}
		else {
			printf("Not one\n");
			}
		for (i=0; i<10; i++) {
			int x = i*2;
			do_something_else(x);
			}
		}

I think I needed therapy after encountering this. :-P


T

-- 
Let's eat some disquits while we format the biskettes.


More information about the Digitalmars-d-learn mailing list