"The nice thing about standards is that there are so many to choose between".

Subject: Uses of block markers in coding

GNU recommends a standard with block-markers aligned under each other and a 
number of people - including myself - find it senseless and 
counter-progressive to keep up an older standard resting from old days and 
doing the programmer a disfavor.

Too many programmers continue to use a style that originates back to the 
days where dumb terminals with one-line memory and line-editors was common.

Those days it could take long time to submit a line to the mainframe. I 
have tried it myself and in worst-case situations it could take up to half 
a minute to submit a line.

So naturally we put more things into one line. Statements like

if (tempratureM1>=tempratureSTP) {cout << "Warning! Cooling needed"; 
log(tempratureM1, "Warning);};

all in one line.

When editors became a little faster people started to write:

if (tempratureM1>=tempratureSTP)  {
   cout << "Warning! Cooling needed"; log(tempratureM1, "Warning); }

which is nicer to look at but would take many seconds more as one more line 
has to be submitted.

- - -

Nowadays few people have any problems with waiting for a CR.

But for mysterious reasons a rest from the old forced "standard" remains 
among people who use C(++) like languages.

It is still standard to write

if (some_expression) {

What the "{" - the marking of the beginning of a block that should be 
indented - is doing in the end of the line nobody has yet been able to 
explain me.

Why, then, are functions not written as

function foo(parameter1, foo(parameter1, parameter2, ... parameterN) {


In other block-structured languages you of course align block-markers under 
each other, allowing for easy scan.

if expression

I have yet to see anybody write

if expression begin

- - -

Does it matter? Oh, yes it does. A lot. As teacher I know from experience 
that programmers has a harder time tracking their own block with a number 
of "{"s dancing far out of sight in the right side of the screen. This is 
not a matter of experience. No experience can ever make it equally fast to 
control structures based on vertically aligned block-markers contra those 
where the marker can be found anywhere on a line.

As an amusing result of the weird practice it has been necessary to 
recommend a standard where the { }-pair is always used, even though there 
is only one statement following an if:

if ($myvarirable1*myvariable2 >= myvariable3*myvariable4+114) {

instead of simply

if ($myvarirable1*myvariable2 >= myvariable3*myvariable4+114)

Why the need for the extra "{ }"s?

Of course because the the difference between

if ($myvarirable1*myvariable2 >= myvariable3*myvariable4+114)

(correct) and

if ($myvarirable1*myvariable2 >= myvariable3*myvariable4+114)  {

(wrong) is easily overlooked because of the block marker put away to the right!

But nobody overlooks the difference betweeen

if ($myvarirable1*myvariable2 >= myvariable3*myvariable4+114)


if ($myvarirable1*myvariable2 >= myvariable3*myvariable4+114)

where the missing "}" shines in the eyes.

- - -

We can only hope that some major standard-setters for PHP should make a 
rational decision about what standard to choose and not just keep "what we 
are used to" for the disadvantage of future generations of programmers.


Best regards

U5com Co Ltd.

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to