[phobos] phobos commit, revision 2098

spir denis.spir at gmail.com
Tue Jan 4 10:17:05 PST 2011


On Tue, 4 Jan 2011 07:35:17 -0800 (PST)
Steve Schveighoffer <schveiguy at yahoo.com> wrote:

> I prefer no full bracing, and braces on their own line.
> 
> The only thing I'd say is that bracing is required on nesting.  i.e. this is ok:
> 
> if(x)
>    blah();
> else
>    bleh();
> 
> but this is not:
> 
> if(x)
>    if(y)
>       blah();
>    else
>       bleh();
> 
> should be:
> 
> if(x)
> {
>    if(y)
>      blah();
>    else
>      bleh();
> }

About nested blocks, I think and do the same in practice: omit braces only for a single line, even if the block is a single (compound) statement.
In addition, when no bracing is required because the block is a single-statement, I would still recommend said statement to be systematically on its own line, meaning *not*

	if (foo) bar = 1;

to still visually show the dependance

	if (foo)
	    bar = 1;

But braces on their own line is simply weird and too much a demand for my taste. I cannot guess any rational advantage; do you really find

	if (cond)
	{
	    this();
	    that();
	}
	else
	{
	    this2();
	    that2();
	}

_logically_ more readible than

	if (cond) {
	    this();
	    that();
	} else {
	    this2();
	    that2();
	}

? Or is it just a question of peronal habit?
Instead, I can very well see the drawbacks; especialy uselessly consuming valuable vertical space on screen ;-) I'm not joking, it's a strong nuisance. (*)

Anyway, why not simply use a pretty printer for officially published code (esp Phobos)? It would be run on code just before uploading on the official repository. So that we have a standard style, while developpers can go on using their preferred style one.

I take the opportunity to ask for the rationale of a choice I read on the style guide wiki page: that acronyms should be spelt lowercase (I'm not joking, it's written there http://prowiki.org/wiki4d/wiki.cgi?DProgrammingGuidelines#Abbreviations). For instance: toAscii instead of toASCII. I find this an obstacle to readability; even more so because due to "camel case" rule the first letter usually needs to be capitalised, like in the example. Certainly the advantange of toASCII and the disturbance of toAscii are very moderate ;-) But what is the reason for breaking the common rule?

Finally, how can one expect people to follow guidelines the core language itself does not respect? For instance, very few builtin names are conformant, maybe only by accident (single-word func names). And the library unequally follows the style as well.
I would be for having an implicitely imported module of conformant aliases for core builtin names. And have every std module define conformant aliases as well, for every exported symbol.


Denis

(*) I just discovered vertical space is also greatly eaten by the expectation of ddoc for docs to be placed _before_ what the describe instead of _inside_. (So that one cannot even fold a func's doc with the func itself.) Once more feature python had right at once.
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the phobos mailing list