[Info-vax] Style question, was: Re: Empty blocks in FILES-11 directory files.
Simon Clubley
clubley at remove_me.eisner.decus.org-Earth.UFP
Tue Sep 27 13:56:00 EDT 2022
On 2022-09-25, Mark Daniel <mark.daniel at wasd.vsm.com.au> wrote:
>
> odsptr->Rab.rab$l_ubf = odsptr->DataPtr;
> for (;;)
> {
> if (SizeInBytes > 512*127)
> odsptr->Rab.rab$w_usz = 512*127;
> else
> if (SizeInBytes > 0)
> odsptr->Rab.rab$w_usz = SizeInBytes;
> else
> break;
>
I have a style question about this part of Mark's code and was wondering
if this was a common style, or if you always made liberal use of braces
to help draw attention to the nesting going on here and to help avoid
some later editing mistakes.
For example, I would write this code section as something like this:
if (SizeInBytes > 512*127)
{
odsptr->Rab.rab$w_usz = 512*127;
}
else
{
if (SizeInBytes > 0)
{
odsptr->Rab.rab$w_usz = SizeInBytes;
}
else
{
break;
}
}
(and yes, wrapping single statements in braces is also deliberate here.)
For me, I find the liberal use of braces helps to draw attention to the
code structure, is more readable in general (at least to me), and helps
avoid some mistakes during later editing.
Just wondering which is the more common style in the C code you have seen.
> status = sys$read (&odsptr->Rab, 0, 0);
> if (VMSnok (status)) break;
>
> odsptr->DataLength += odsptr->Rab.rab$w_rsz;
> odsptr->Rab.rab$l_ubf += odsptr->Rab.rab$w_rsz;
> SizeInBytes -= odsptr->Rab.rab$w_rsz;
> }
>
> sys$close (&odsptr->Fab, 0, 0);
Simon.
PS: Yes, Simon's a Whitesmiths fan. Other indentation styles are available. :-)
--
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
More information about the Info-vax
mailing list